可以創(chuàng)建C++、C#、Python、Golang、Java、React、Node、Vue、PHP項目
創(chuàng)建Java項目
創(chuàng)建Python項目
?簡單if……else……語句
# 簡單的if……else……語句
state = True
if state:
print("狀態(tài)正常")
else:
print("狀態(tài)異常")
# 復雜的if……elif……語句
score = 88
def __getlevel__(score):
level = ""
if score >= 85 and score <=100:
level = "A"
elif score >=70 and score < 85:
level = "B"
elif score >=60 and score < 70:
level = "C"
elif score < 60:
level = "D"
return level
level = __getlevel__(score)
print("my level is :"+level)
# 嵌套if語句
Python從入門到精通
'''
條件語句
'''
# 普通if……else……語句
# 定義變量 存放狀態(tài)
state = True
# 定義函數(shù) 計算狀態(tài)
def getState(state):
if state:
print("狀態(tài)啟用")
else:
print("狀態(tài)關(guān)閉")
# 調(diào)用函數(shù) 打印狀態(tài)
getState(state)
# if……elif……語句
# 定義變量 存放得分
scored = 78
# 定義函數(shù) 計算等級
def getLevel(scored):
# if else條件語句
if scored >= 85 and scored <= 100:
print("A")
elif scored >= 70 and scored <= 84:
print("B")
elif scored >= 60 and scored <= 69:
print("C")
else:
print("D")
# 調(diào)用函數(shù) 打印等級
getLevel(scored)
# if……else語句嵌套
# while循環(huán)語句
j = 1
# 簡單while循環(huán)語句
while j < 10:
print(j)
j += 1
# while語句中使用 break、continue跳出循環(huán)
# while循環(huán)中使用break語句用于跳出整個循環(huán)
x = 0
while x < 10:
x += 1
if x % 2 == 0:
break
print("x:" + str(x))
# 輸出 x:1
# while循環(huán)中continue語句用于跳出本次循環(huán)
while x < 10:
x += 1
if x % 2 == 0:
continue
print("x:" + str(x))
# 輸出 x:1 x:3 x:5 x:7 x:9
# while……else……語句
# for循環(huán)語句
for i in range(1, 10):
print("for:" + str(i))
# 循環(huán)字符串
for i in "python":
print(i)
# 循環(huán)元組
# for……else……語句
for i in range(1,10):
print(i)
# pass語句就是
if state:
print("True")
else:
pass
print("False")
?文章來源地址http://www.zghlxwxcb.cn/news/detail-769965.html文章來源:http://www.zghlxwxcb.cn/news/detail-769965.html
?
到了這里,關(guān)于Python從入門到網(wǎng)絡爬蟲、自動化的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!