print
隔行 / 连续 / 间隔输出print(a) == print(a,end='\n')print(a, end='')print(a, end=' ')
/
(除)(-13)/3 = -5# 3*(-5)<-13<3*(-4)
%
(取模)(-13)%3 = 2# |(-13)-(-15)| = 2
if
语句if a<b:elif a>b: #用于再判断else:
while
语句while true: if a < b: break #不再执行后面的语句,跳出while循环 elif a > b: continue #不再执行后面的语句,重新while循环 else:else:
for
语句for a > b:else: 可选
range(a,b)
左包括右不包括range(1,4) = [1,2,3]range(1,4,2) = [1,3]
# 函数里的变量只在函数内部有效x =50def func(x): print('x is', x) x = 2 print('Changed local x to', x)func(x)print('x is still', x)# 输出x is 50changed local x to 2x is still 50
global
语句x =50def func(): global x print('x is', x) x = 2 print('Changed global x to', x)func()print('Value of x is', x)# 输出x is 50changed global x to 2value of x is 2
def func(a, b=5) #有效def func(a=5,b) #无效
def max(a,b): '''选取最大值'''help(max)# 输出max(a,b) 选取最大值
zip
命令本文的文字及图片来源于网络加上自己的想法,仅供学习、交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理。
联系客服