V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
jakeyfly
V2EX  ›  问与答

Python 中有没有什么专门操作时间的库,应用场景在贴内

  •  
  •   jakeyfly · 2018-03-16 15:37:16 +08:00 · 1312 次点击
    这是一个创建于 2246 天前的主题,其中的信息可能已经有所发展或是发生改变。

    应用场景比如: 判断 时间是否是早上 10:30 之后 如果是就开始执行一些代码。有没有方便比较时间的类库啊

    7 条回复    2018-03-17 02:58:05 +08:00
    manzhiyong
        1
    manzhiyong  
       2018-03-16 15:47:35 +08:00
    jakeyfly
        2
    jakeyfly  
    OP
       2018-03-16 16:03:05 +08:00
    @manzhiyong 试了一下 好像不知道怎么把这种'2018,2,17,01,30,00' 转换成时间
    Marfal
        3
    Marfal  
       2018-03-16 16:12:34 +08:00
    想歪了
    goofool
        4
    goofool  
       2018-03-16 17:42:38 +08:00
    datetime 就可以有,用系统的 crontab 也可以哇,都是现成的
    jakeyfly
        5
    jakeyfly  
    OP
       2018-03-16 17:55:50 +08:00
    @goofool 用 datetime 试了下 碰到不少问题不理解,只有 datetime 对像才能比较时间大小啊,当前时间的 datetime 对像只会在最后跟 一个时区 不能跟 转换成 datetime 对像的指定时间 比较
    goofool
        6
    goofool  
       2018-03-16 18:21:04 +08:00
    datetime.now().hour > 10 ?
    crazykuma
        7
    crazykuma  
       2018-03-17 02:58:05 +08:00 via Android
    arrow ?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1013 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 20:08 · PVG 04:08 · LAX 13:08 · JFK 16:08
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.