二、三大语句
# 二、三大语句
# 2.1 顺序语句
# 2.1.1 链式赋值(雷!狗都不用)
a = b = c= 1
print(a,b,c)
a = b = c = {'age':99}
b['age'] = 11
print(a,b,c)
1
2
3
4
5
6
7
2
3
4
5
6
7
1 1 1
{'age': 11} {'age': 11} {'age': 11}
# 2.1.2 try catch
try:
1/1
except:
print('there are something wrong!!!')
else:
print('God job')
finally:
print('END')
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
God job
END
# 2.2 条件语句
flag = 1991
if flag < 100 and True:
print('Hello Douaa')
elif flag < 200 and 1==1:
print('Hello Adam')
else:
print('hello China')
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
hello China
# 2.3 循环语句
# 跳出循环 break、continue
# while 循环
num = 0
while num < 3:
num +=1
print(num)
else:
print('end')
1
2
3
4
5
6
7
2
3
4
5
6
7
1
2
3
end
# for 循环
nums = range(1,10)
for num in nums:
print(num)
else:
print('End')
1
2
3
4
5
2
3
4
5
1
2
3
4
5
6
7
8
9
End