input() vs sys.stdin.read()
问题 import sys s1 = input() s2 = sys.stdin.read(1) #type "s" for example s1 == "s" #False s2 == "s" #True Why? How can I make input() to work properly? I tried to encode/decode s1 , but it doesn't work. Thank you. 回答1: If you're on Windows, you'll notice that the result of input() when you type an 's' and Enter is "s\r" . Strip all trailing whitespace from the result and you'll be fine. 回答2: You didn't say which version of Python you are using, so I'm going to guess you were using Python 3.2