This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
标题: Python 3.2 input() does not remove "\r" at the end of returned string.
类型: behavior Stage: resolved
Components: Windows Versions: Python 3.2
process
状态: closed Resolution: duplicate
Dependencies: 后续: input() has trailing carriage return on windows
View: 11272
分配给: 抄送列表: Trundle, jaylogan
优先级: normal 关键字:

Created on 2011-03-07 17:22 by jaylogan, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg130265 - (view) Author: Joshua Logan (jaylogan) 日期: 2011-03-07 17:22
Hello,

It is mentioned in the documentation for input() ( http://docs.python.org/py3k/library/functions.html#input ) that the newline is stripped from the end of the returned string. However, on Windows, it used to trim '\r\n'. Now it no longer trims '\r'.

See output below:

C:\>python
Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win32

>>> name = input("What's your name? ")
What's your name? Josh
>>> print(name)
Josh
>>> print(list(name))
['J', 'o', 's', 'h', '\r']
msg130266 - (view) Author: Andreas Stührk (Trundle) * 日期: 2011-03-07 17:23
This is a duplicate of issue #11272.
历史
日期 用户 动作 参数
2022-04-11 14:57:14admin修改github: 55643
2011-03-07 17:30:43r.david.murray修改状态: open -> closed
抄送: jaylogan, Trundle
后续: input() has trailing carriage return on windows
resolution: duplicate
stage: resolved
2011-03-07 17:23:50Trundle修改抄送: + Trundle
消息: + msg130266
2011-03-07 17:22:22jaylogan创建