您可以使用
threading
包来完成此操作。这让你基本上有2个
while
循环同时运行。在您的情况下,一个用于输入,另一个用于其他代码。这里有一些代码可以做到这一点。
itemA = False
itemB = False
itemC = False
import threading
def execute_code():
while True:
# execute code (not waiting for input)
print("hi")
continue
threading.Thread(target=execute_code).start()
while True:
input("input example")
# execute code (waiting for input)