新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
創(chuàng)新互聯(lián)Python教程:python中的分支有幾種形式
【相關(guān)學(xué)習(xí)推薦:python教程】

python中的分支有三種形式,分別是:
1、if
#!/usr/bin/env python
#-*- coding:utf-8 -*-
user=input('Please input your username : ')
if user=='admin':5 print('Nice')2、 if ... else ...
#!/usr/bin/env python
#-*- coding:utf-8 -*-
user=input('Please input your username : ')
pass=input('Please input your password: ')
if user=='admin' and pass=='123456':
print('Good')
else:
print('Bad')3、if ... elif ... else ...
#!/usr/bin/env python
#-*- coding:utf-8 -*-
grade=(prompt='Please input your grade')
if grade>=85:
print('Great')
elif garde<85 and grade>=70:
print('Good')
else grade<70:
print('Bad') 文章標(biāo)題:創(chuàng)新互聯(lián)Python教程:python中的分支有幾種形式
文章鏈接:http://www.dlmjj.cn/article/cosccjs.html


咨詢(xún)
建站咨詢(xún)
