python 中的延迟

发布于 2024-11-05 14:01:35 字数 1187 浏览 1 评论 0原文

我在 python 上创建了一个问答游戏,基本上用户回答了我随机提出的一些问题,然后按 Enter 键,它会说“计算你的聪明度”,并会在屏幕上显示一个随机数字。 问题是,每次用户按下回车键时,它都会说“计算你的聪明度”并同时显示数字。我想知道如何在开始下一个代码/行/脚本之前添加延迟。?

这是我到目前为止的代码

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")

,谢谢。 :)

I Created a quiz game on python, where basically the user answers some questions i randomly made up and after that they press enter, it will say " calculating you smartness " and will show a random number on your screen.
problem is,everytime the user press enter it will say "calculating your smartness" and shows the number at the same time. im wondering how to add a delay before starting the next code/line/script.?

here is my code so far

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")

please and thank you. :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

向日葵 2024-11-12 14:01:35

time 模块的 sleep()

另外,由于某种原因您已经导入了它。

time module's sleep()

Also, you already have it imported for some reason.

甜扑 2024-11-12 14:01:35

使用 time.sleep(secs),请参阅此处:http ://docs.python.org/library/time.html#time.sleep

指尖凝香 2024-11-12 14:01:35

您正在寻找 time.sleep()

You're looking for time.sleep().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文