首页
学习
活动
专区
圈层
工具
发布
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    Python时间,日期,时间戳之间转换

    1.将字符串的时间转换为时间戳    方法:        a = "2013-10-10 23:40:00"        将其转换为时间数组        import time        ...time.strptime(a, "%Y-%m-%d %H:%M:%S")    otherStyleTime = time.strftime("%Y/%m/%d %H:%M:%S", timeArray) 3.时间戳转换为指定格式日期...otherStyleTime = dateArray.strftime("%Y-%m-%d %H:%M:%S")        otherStyletime == "2013-10-10 23:40:00" 4.获取当前时间并转换为指定日期格式...   方法一:        import time        获得当前时间时间戳        now = int(time.time())  ->这是时间戳        转换为其他日期格式...("%Y-%m-%d %H:%M:%S") 5.获得三天前的时间    方法:        import time        import datetime        先获得时间数组格式的日期

    4K10
    领券