Nic*_*kin 2 python input python-3.x spyder
该input()函数使用WinPython 3.3.5在Spyder IDE中的某些输入上返回奇怪的值:
>>>input('say:')
say:hello
hello
>>>input('say:')
say:hello!
hello!
>>>input('say:')
say:!
'evalsc(r"!")'
>>>input('say:')
say:!123
'evalsc(r"!123")'
>>>s = input('say:')
say:!
>>>type(s)
<class 'str'>
>>>repr(s)
'\'evalsc(r"!")\''
Run Code Online (Sandbox Code Playgroud)
为什么input()以这种奇怪的方式处理领先的惊叹号?
有趣的是,如果我从命令行运行相同的python,一切正常.但是,在Spyder IDE中,它让我变得愚蠢.