datetime库运用

1.  date(),time(),datetime() 时间数据概用:
      

2.  datetime.datetime.now()    获取当前时间

   datetime.datetime.utcnow()  获取格林威治当前时间

 3.  datetime.datetime.strptime("Aug-6-18 21:19","%b-%d-%y %H:%M")  解析时间

    

4.  datetime.datetime.strftime

   now = datetime.datetime.now()

   strf = now.strftime("%Y-%m-%d %H:%M:%S")      年-月-日   时:分:秒 格式

   strf2 = now.strftime("%m-%d-%Y %H:%M:%S")      月-日-年  时-分-秒  格式

    

  

猜你喜欢

转载自www.cnblogs.com/cxhzy/p/9943270.html