我是一个初学者,想知道是否有任何机制可以在 python 中执行 while 循环。
我只尝试了 for 和 while 循环,但仍然没有找到任何方法来执行循环体,即使条件仍然为 false。
试试这个:
while True: user_input = input("Input a string (or 'q' to quit): ") if user_input == 'q': break print(user_input)