开发者

Python raw_input("") error

I am writing a simple commandline script that uses raw_input, but it doesn't seem to work.

This code:

print "Hello!"
raw_inp开发者_C百科ut("")

Produces this error:

Traceback (most recent call last):
 File "<pyshell#6>", line 1, in <module>
raw_input("")
TypeError: 'str' object is not callable

I have never encountered this error before, and couldn't find anything on Google. I am using Python 2.6 on Windows 7.


It appears you are using something called pyshell. There is likely a bug there in that shell itself. Try just using vanilla bash.


Works fine as presented, e.g. in an interpreter prompt in any Python 2 version:

>>> print "Hello!"
Hello!
>>> raw_input("")
bah
'bah'
>>> 

where bah is what I typed after the code you gave in response to the empty-prompt;-).

The only explanation for the error you mention is that you've performed other code before this, which included binding identifier raw_input to a string.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜