码迷,mamicode.com
首页 > 编程语言 > 详细

python day2

时间:2018-04-06 12:29:08      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:min   today   src   closed   isp   int   this   sed   none   

技术分享图片
from datetime import datetime
odds=[1,3,5,7,9,11,13,15,17,19,
      21,23,25,27,29,31,33,35,37,39,
      41,43,45,47,49,51,53,55,57,59]
for i in range(60):
    import time
    import random
    time.sleep(random.randint(1,60))
    right_this_minute=datetime.today().minute
    if right_this_minute in odds:
        print("This minute seems a little odds.")
    else:
        print("Not an odd minute.")
View Code

优化

from datetime import datetime
import time
import random
odds=[1,3,5,7,9,11,13,15,17,19,
      21,23,25,27,29,31,33,35,37,39,
      41,43,45,47,49,51,53,55,57,59]
for i in range(5):

    right_this_minute=datetime.today().minute
    if right_this_minute in odds:
        print("This minute seems a little odds.")
    else:
        print("Not an odd minute.")
    wait_time=random.randint(1,50)
    print(wait_time)
    time.sleep(wait_time)

 

python day2

标签:min   today   src   closed   isp   int   this   sed   none   

原文地址:https://www.cnblogs.com/ice777/p/8726880.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!