平台:Git bash MINGW64,Windows 7,64 CMD 当我从Learn Python The Hard Way ex11运行Python代码时。代码很简单。当运行Python代码时,Cmd和Git bash有不同的结果
print "How old are you?",
age = raw_input()
print "How tall are you?",
height = raw_input()
print "How much do you weigh?",
weight = raw_input()
print "So, you're %r old, %r tall and %r heavy." % (
age, height, weight)
但它们在CMD和Git bash中有不同的结果。当我使用Git bash运行它时,raw_print()将首先运行。
当您输入3个答案时,最后会显示4个打印。当我在CMD中运行它时,它通常显示一个打印,一个raw_input()
。
有人可以解释吗?
编辑:其实我的目标是解释原因,而不是用flush来解决这个问题。所以它与this question不一样
【如何刷新蟒纹的输出?](http://stackoverflow.com/questions/230751/how-to-flush-output-of-python-print) –
@KevinGuan我的可能的复制已编辑它。其实,我的目标是解释原因,而不是用冲水来解决这个问题。所以它与另一个问题是不同的。来自回答者MitchPomery的缓冲模式击中了关键。 – naifan