正如标题所说,
我在Edx.org上提交Pset时得到“EOFError”。 我做“计算机科学导论和使用Python编程”
问题集鼓励我使用raw_input(),但没有Stdin或任何其他输入控制台,因此给我这个错误:
>Traceback (most recent call last):
> File "submission.py", line 110, in <module>
> hangman(secretWord)
> File "submission.py", line 95, in hangman
> userInput(lettersGuessed)
> File "submission.py", line 9, in userInput
> choice= raw_input("Please guess a letter: ").lower()
>EOFError: EOF when reading a line
import string
import random
def userInput(lettersGuessed):
choice= raw_input("Please guess a letter: ").lower()
if len(choice)==1 and choice in string.ascii_lowercase: #this is to check wether the user misstyped a number or special character instead of letter"
if choice not in lettersGuessed:
return lettersGuessed.append(choice) ,validateGuess(choice)
else:
print "Oops! You've already guessed that letter: " + getGuessedWord(secretWord, lettersGuessed)
return userInput(lettersGuessed)
else:
print "Only a single letter allowed!"
return userInput(lettersGuessed)