Python EOF error raw_input()

后端 未结 1 2047
隐瞒了意图╮
隐瞒了意图╮ 2020-12-07 05:24

I\'m using Zed Shaw\'s Learn Python the Hard Way.

In exercise 11, the code produces an EOF error on line 2. Here is the code:

1         


        
相关标签:
1条回答
  • 2020-12-07 06:02

    The problem is that online interpreters usually don’t pause to allow the user to input stuff. Instead, they will use a fixed “file” as stdin from which the data is read. Unless you specify it, it will be empty, so asking for input will result in EOF since the (empty) file was already exhausted.

    It is possible to specify the input data though. On ideone, you have to click the stdin button and enter the data at once. For example:

    old
    tall
    weight
    

    Then your script will run.

    But you really should consider downloading Python yourself and running it in the command line with a normal interpreter. That way, you actually get some interactivity.

    0 讨论(0)
提交回复
热议问题