V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
911speedstar
V2EX  ›  Python

怎么随机休息几秒呢

  •  
  •   911speedstar · 2019-03-09 20:36:24 +08:00 · 2437 次点击
    这是一个创建于 1864 天前的主题,其中的信息可能已经有所发展或是发生改变。
    原代码里是 time.sleep(5),

    怎么改为让程序随机休息几秒呢,比如这次循环是休息 1s,下次就 3s,下下次 5s。这样子的
    ClutchBear
        1
    ClutchBear  
       2019-03-09 20:56:50 +08:00   ❤️ 1
    random。randint ( 1,5 )
    Heyavc
        2
    Heyavc  
       2019-03-10 08:07:38 +08:00
    random 随机数
    wanderpoet
        3
    wanderpoet  
       2019-03-10 15:15:44 +08:00 via iPhone
    sleep + random
    yingfengi
        4
    yingfengi  
       2019-03-10 15:54:21 +08:00   ❤️ 2
    随机卡顿好下次优化吗 (狗头.gif )
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5557 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 07:54 · PVG 15:54 · LAX 00:54 · JFK 03:54
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.