1 continue,break
a=True
while a:
b=input("Type something:\n")
if(b=='1'):
a=False
else:
pass
pass:什么都不做
结果:
D:\PycharmProjects\pythonProject\venv\Scripts\python.exe D:/PycharmProjects/pythonProject/hello.py
Type something:
2
Type something:
2
Type something:
3
Type something:
1
Process finished with exit code 0
如果用break:
while True:
b=input("Type something:\n")
if(b=='1'):
break
else:
pass
print('still in while')
print('finish run')
运行结果:
D:\PycharmProjects\pythonProject\venv\Scripts\python.exe D:/PycharmProjects/pythonProject/hello.py
Type something:
2
still in while
Type something:
3
still in while
Type something:
1
finish run
Process finished with exit code 0
若是continue: