平臺: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