我在python上创建了一个问答游戏,基本上用户回答一些我随机编造的问题,然后按回车键,它会说“计算你的智能”,并在你的屏幕上显示一个随机数字。问题是,每次用户按回车键时,它都会说“计算你的智能度”,并同时显示数字。我想知道如何在开始下一段代码/行/脚本之前添加延迟。
到目前为止,以下是我的代码
import os
import time
a = raw_input("how old is I?:")
w = raw_input("How many ants are in the world?:")
e = raw_input("why am i asking so many questions:")
s = raw_input("Are mcdonalds food healthier than pizza huts?:")
o = raw_input("Are you fat:")
m = raw_input("show me examples of random:")
e = raw_input("how to eat a chicken without a chicken?:")
e = raw_input("Can you park in reverse while driving forwards while flying?:")
os.system('cls')
print "----------------------"
print "here are your answers!"
print a
print w
print e
print s
print o
print m
print e
print e
print "----------------------------------------------------------"
print 'now calculating smartness:'
print "Your smart level is:"
import random
print random.randint(1,100)
print "----------------------------------------------------------"
print "aw c'mon you can do better than that!!!!"
print "----------------------------------------------------------"
raw_input("Press enter to quit the game")谢谢你,谢谢。:)
发布于 2011-05-04 17:58:20
time module's sleep()
此外,由于某些原因,您已经导入了它。
发布于 2011-05-04 17:59:08
使用time.sleep(secs),查看此处:http://docs.python.org/library/time.html#time.sleep
发布于 2011-05-04 17:59:45
你在找time.sleep()。
https://stackoverflow.com/questions/5881605
复制相似问题