擅长:python、mysql、java
<p>我想我明白了。如果你这样写,那么你可以第一次运行它。但从第二次开始就不会执行了。因为jupyter只清除代码块输出,而不释放while循环。在</p>
<pre><code>while True:
a = input("Input a number: ")
if a.isdigit():
string_container += a + "\n"
add_container += int(a)
else:
if a == 'A':
print(Add_container)
else:
if a == 'T':
print(string_container)
else:
if a=="q":
os._exit(0)
else:
print("invalid input")
</code></pre>
<p>你应该把你的代码放在一个try-catch块中,就像这样。在</p>
^{pr2}$
<p>所以你必须</p>
<pre><code>1. Select restart the kernel and clear output
2. Add try-catch so you can use "kernel interrupt" to kill the while loop
3. Whenever you finish using this while loop, select "kernel" -> "interrupt" to kill it completely
</code></pre>
<p>希望有帮助</p>