【发布时间】:2016-01-08 03:20:18
【问题描述】:
平台:Git bash MINGW64、Windows 7、64 CMD 当我从Learn Python The Hard Way ex11 运行 Python 代码时。代码很简单。
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不同
【问题讨论】:
-
@KevinGuan 我已经编辑过了。实际上,我的目标是解释原因,而不是用flush解决这个问题。所以这与另一个问题不同。回答者 MitchPomery 的缓冲模式是关键。