hao1nan 发表于 2018-8-11 13:34:45

python 时间模块备忘

# python time1.py  
1425623399.84
  
time.struct_time(tm_year=2015, tm_mon=3, tm_mday=6, tm_hour=14, tm_min=29, tm_sec=59, tm_wday=4, tm_yday=65, tm_isdst=0)
  
2015-03-06
  
15-03-06
  
2015-03-06 14:29:59
  
2015-03-06 02:29:59
  
2015-03-06 14:29:59 --Friday--Fri Mar6 14:29:59 2015
  
2015-03-06 14:29:59 --03/06/15--14:29:59
  

  

  
datetime模块定义了下面这几个类:
  
datetime.date:表示日期的类。常用的属性有year, month, day;
  
datetime.time:表示时间的类。常用的属性有hour, minute, second, microsecond;
  
datetime.datetime:表示日期时间。
  
datetime.timedelta:表示时间间隔,即两个时间点之间的长度。
  

  

  
>>> from datetime import *
  
>>> print datetime.today()
  
2015-03-06 14:43:46.870936
  
>>> print datetime.now()
  
2015-03-06 14:43:51.313098
页: [1]
查看完整版本: python 时间模块备忘