break、continue、exit
break: 跳出整个循环 不会再执行循环后面的内容
continue: 跳出本次循环,continue后面的代码内容也不会被执行
exit( ): 结束整个程序的运行
for i in range(10):
if i == 5:
continue
print('python')
#break
#exit()
print(i)
print('hello')
结果
命令行提示符
import os
# print(os.system('ls'))
# print(os.system('pwd'))
for i in range(1000):
cmd = input('[test@ ~]$ ]')
if cmd:
if cmd == 'exit':
print('logout')
break
else:
print('run %s' %(cmd))
# 运行shell命令
os.system(cmd)
else:
continue