github_37430159
shaw-lib
2017-02-01 03:50

【Python】新手求助!~

  • eoferror

代码如下:

#一直执行循环直到敲了ctrl+d
try:
    while True:#循环抽题
        snippets = PHRASES.keys()
        random.shuffle(snippets)#随机打乱顺序

        for snippet in snippets:#抽题
            phrase = PHRASES[snippet]
            question, answer = convert(snippet, phrase)
            if PHRASE_FIRST:
                question, answer =answer, question

            print question

            raw_input(" >")
            print "ANSWER: %s\n\n" % answer
except EOFError:
    print '\nBye!'

敲了 ctrl+d 触发不了EOFErro
而是直接执行了下一步。

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答