zoukankan      html  css  js  c++  java
  • python中time模块和datetime模块

    time模块和datetime模块

    时间分为三种模式(time 模块)

    1. 时间戳   (time.time())

    2. 格式化字符串 (time.strftime(%Y-%m-%d %H:%M:%S %p))

    3. 结构化的时间对象  (time.localtime()  time.gmtime())

      import time
      print(time.localtime())
      print(time.localtime().tm_hour)
      print(time.localtime().tm_wday)
      print(time.localtime().tm_yday)
      print(time.gmtime())
      #时间转换
      #时间戳---->struct_time------->格式化的字符串
      import time
      struct_time=time.localtime(123123)
      print(struct_time)
      ​
      print(time.strftime('%Y-%m-%d',struct_time))
      ​
      #格式化的字符串---->struct_time------->时间戳
      struct_time=time.strptime('2017-03-11','%Y-%m-%d')
      print(struct_time)
      ​
      print(time.mktime(struct_time))
      ​
      ​
      import datetime   #datetime模块
      print(datetime.datetime.now())
      ​
      print(datetime.datetime.fromtimestamp(1231231))
      ​
      print(datetime.datetime.now() + datetime.timedelta(days=3))
      print(datetime.datetime.now() - datetime.timedelta(days=3))
      print(datetime.datetime.now() + datetime.timedelta(days=-3))
      print(datetime.datetime.now() + datetime.timedelta(days=3,hours=3))
  • 相关阅读:
    GoldenGate V11.1数据复制限制
    OGG切换步骤
    GoldenGate 1403错误解决方法
    logsource and ALO
    使用HANDLECOLLISIONS的几个场景
    Goldengate参数规范
    GoldenGate 进程
    Goldengate进程的合并与拆分规范
    url的组成结构信息
    Python中容器指的是什么?
  • 原文地址:https://www.cnblogs.com/5j421/p/10072758.html
Copyright © 2011-2022 走看看