2016-07-21 6 views
0

私はWindowsターミナルでPythonプログラムを実行すると、挿入された変数(%s)のテキストがうまくいきません。cmdの入力に問題があります

コード:

print("Hi! What's your name?") 
name = input("name: ") 
print("Nice to meet you %s" % name) 
print("%s is a good name." % name) 
print("This line is only to test %s in the middle of the text." % name) 
input("press enter to exit") 

Pythonシェルでの結果:CMDで

Python Shell Result

結果:

cmd result

私はケースでWindows 10およびpython32を使用していますあなたは知る必要があった。

+2

興味深いことに、 '%'の代わりに 'format'を使用して結果を投稿してください。 – Rockybilly

+0

Win8.1でうまく動作します。私はWindowsのコマンドラインから実行し、出力はあなたのPythonシェルの結果と似ています。 –

+0

窓の下で私のために働く –

答えて

0

これはWindows上の3.2.0のバグです。 input()ステートメントは "\ n"は削除されますが、 '\ r'は削除されないため、文字列入力は非表示になります。

name = input("name: ").rstrip() 

それは3.2.1で修正されました:

https://bugs.python.org/issue11272

クイックフィックスを参照してください。あなたは本当にあなたのPythonをアップグレードする必要があります!

+0

私は更新され、すべてがうまくいきます!ありがとう。 – CyManSAP

関連する問題