我们必须使用什么键盘命令来停止Python中的无限循环?

任何循环都可以执行一定次数或直到满足特定条件为止。但是,如果没有出现这种情况,循环将无限重复。需要通过产生键盘中断来强制停止这种无限循环。按下Ctrl-C会停止执行无限循环

>>> while True:
print ('hello')


hello
hello
hello
hello
hello
hello
Traceback (most recent call last):
File "<pyshell#18>", line 2, in <module>
print ('hello')
KeyboardInterrupt