一、格式化输出format&占位符
name = input('please input your name:') age = input('plecse input your age:') height = input('please input your height:') #两个%%目的是转义,则表示为百分比的意义,若只有一个%,则表示为占位符的意义 print('我的名字是%s,我的年龄是%d,我的身高是%d,学习进度为5%%' %(name,int(age),int(height)))
二、while else
1、当while循环没有被break打断时,走else;被break打断时,不走else
#当循环被break打断,就不会执行else结果 count = 0 while count <= 5: count += 1 if count == 3: break print('Loop',count) else: print('循环正常执行完了') #当循环正常执行完毕,未被break打断,就会执行else结果 count = 0 while count <= 5: count += 1 if count == 3: pass print('Loop',count) else: print('循环正常执行完了')