【发布时间】:2018-04-19 14:36:04
【问题描述】:
我想知道这是否可能。我想要一个无限的while循环,但仍然不会在while循环之外的其余代码在循环打开时继续运行。例如,在每次迭代后打破 while 循环的方法。我需要找到一种方法来执行第二个打印语句,而不会完全破坏 while 循环。
while True:
print('i will loop forever')
print('this code will never be executed because of the while loop')
【问题讨论】:
-
使用多线程,在python中有很多选项可以做到这一点。
-
好像你想使用线程,阅读它们。
标签: python