[英]timer not working in python 2.7
我在家里使用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"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.