Python PyCharm Jupyter笔记本打印()在输入()后显示

Python PyCharm Jupyter笔记本打印()在输入()后显示,python,input,jupyter-notebook,pycharm,Python,Input,Jupyter Notebook,Pycharm,在PyCharm的Jupyter笔记本中,我会有如下代码: print("apple, orange, cherry") fruit = input("Enter a fruit from the list") 输入语句将首先显示,输入水果后,打印语句将在输入后显示。本质上,用户不知道输入哪个水果,因为它在输入语句之后才会显示。将您的print语句更改为: print("apple, orange, cherry", flush=Tr

在PyCharm的Jupyter笔记本中,我会有如下代码:

print("apple, orange, cherry")
fruit = input("Enter a fruit from the list")

输入语句将首先显示,输入水果后,打印语句将在输入后显示。本质上,用户不知道输入哪个水果,因为它在输入语句之后才会显示。

将您的
print
语句更改为:

print("apple, orange, cherry", flush=True)
它应该显示在
input
语句之前