我正在使用Python 2.7进行一些家庭编码,我无法弄清楚为什么这段代码不起作用。我尝试它并且它工作正常,但是说我在-0.000938375024452秒做了... 任何帮助非常感谢
import timeit
import time
alphabet = "abcdefghijklmnopqrstuvwxyz"
again = "yes"
print "Hi."
time.sleep(1)
print "How quick can you type the alphabet?"
time.sleep(1)
print "Well you're about to find out..."
while "YES" in again.upper():
time.sleep(2)
begin = raw_input("When you are ready, press enter and type the alphabet.")
start = timeit.timeit()
attempt1 = raw_input("")
end = timeit.timeit()
time1 = end - start
if attempt1.upper() == alphabet.upper():
print "Ok. You did it in..."
time.sleep(1)
print time1,"seconds!"
time.sleep(1)
again = raw_input("Would you like another go?")
else:
print "Sorry, but that was incorrect."
time.sleep(1)
print "Try again."
again = "yes"
答案 0 :(得分:1)