python中的时间延迟

时间:2013-05-09 23:47:26

标签: python

如何在python中制作一些小延迟?

我希望在之后3秒钟显示某些内容,然后让用户输入内容。

这就是我所拥有的

print "Think of a number between 1 and 100"
print "Then I shall guess the number"

我想要延迟

print "I guess", computerguess
raw_input ("Is it lower or higher?")

3 个答案:

答案 0 :(得分:3)

这应该有效。

import time
print "Think of a number between 1 and 100"
print "Then I shall guess the number"

time.sleep(3)

print "I guess", computerguess
raw_input ("Is it lower or higher?")

答案 1 :(得分:2)

试试这个:

import time

print "Think of a number between 1 and 100"
print "Then I shall guess the number"

time.sleep(3)

print "I guess", computerguess
raw_input ("Is it lower or higher?")

数字3表示暂停的秒数。阅读here

答案 2 :(得分:2)

    import time

    print "Think of a number between 1 and 100"
    print "Then I shall guess the number"

    time.sleep(3) 

    print "I guess", computerguess
    raw_input ("Is it lower or higher?")