gpt4 book ai didi

python - for循环迭代之间的延迟(python)

转载 作者:行者123 更新时间:2023-12-02 02:31:40 39 4
gpt4 key购买 nike

this在Python中可以吗?我用 Python 编写了一个很棒的循环/脚本,如果可能的话,我想添加这个延迟。

map(firefox.open, ['http://www.bing.com/search?q=' + str(i) for i in range(x))], [2] * x)

我应该把 sleep(6) 放在哪里?

最佳答案

您可以使用time.sleep(some_seconds)来做到这一点。

from time import sleep

for i in range(10):
print i
sleep(0.5) #in seconds

实现

这是一个很酷的小实现:(将其粘贴到 .py 文件中并运行它)

from time import sleep

for i in range(101):
print '\r'+str(i)+'% completed',
time.sleep(0.1)

map(firefox.open, [' http://www.bing.com/search?q= ' + str(i) for i in range(x))], [2] * x)

关于python - for循环迭代之间的延迟(python),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23198720/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com