在stdout打印之前发出的Python stdin请求

时间:2014-04-06 13:33:35

标签: python printing stdin raw-input

我最近一直在努力学习Python 3.3并遇到问题。这是我正在使用的测试代码:

print('should print before stdin')
x = raw_input('Enter something: ')

以下是输出结果:

>>something
should print before stdin
Enter something:

为什么打印语句会出现在stdin之后?

1 个答案:

答案 0 :(得分:0)

在Python 3.X中,raw_input("")已被删除,因此请使用input()。 请参阅此docs

print('should print before stdin')
x = input('Enter something: ')

<强>输出

should print before stdin
Enter something: yes

Process finished with exit code 0