>>> import datetime
>>> now=datetime.datetime.now()
>>> now.strftime('%a')
'Sun' >>> import datetime
>>> now=datetime.datetime.now()
>>> now.strftime('%A')
'Sunday' >>> import datetime
>>> now=datetime.datetime.now()
>>> now.strftime('%b')
'Sep' >>> import datetime
>>> now=datetime.datetime.now()
>>> now.strftime('%B')
'September' >>> import datetime
>>> now=datetime.datetime.now()
>>> now.strftime('%c')
'09/15/13 21:43:29' >>> import datetime
>>> now=datetime.datetime.now()
>>> now.strftime('%d')
'15' >>> import datetime
>>> now=datetime.datetime.now()
>>> now.strftime('%H')
'21' >>> import datetime
>>> now=datetime.datetime.now()
>>> now.strftime('%I')
'09' >>> import datetime
>>> now=datetime.datetime.now()
>>> now.strftime('%j')
'258' >>> import datetime
>>> now=datetime.datetime.now()
>>> now.strftime('%m')
'09' >>> import datetime
>>> now=datetime.datetime.now()
>>> now.strftime('%M')
'43' >>> import datetime
>>> now=datetime.datetime.now()
>>> now.strftime('%p')
'PM' >>> import datetime
>>> now=datetime.datetime.now()
>>> now.strftime('%S')
'29' >>> import datetime
>>> now=datetime.datetime.now()
>>> now.strftime('%U')
'37' >>> import datetime
>>> now=datetime.datetime.now()
>>> now.strftime('%w')
'2' >>> import datetime
>>> now=datetime.datetime.now()
>>> now.strftime('%W')
'37' >>> import datetime
>>> now=datetime.datetime.now()
>>> now.strftime('%x')
'09/17/13' >>> import datetime
>>> now=datetime.datetime.now()
>>> now.strftime('%X')
'07:55:04' >>> import datetime
>>> now=datetime.datetime.now()
>>> now.strftime('%y')
'13' >>> import datetime
>>> now=datetime.datetime.now()
>>> now.strftime('%Y')
'2013' >>> now.strftime('%%')
'%' >>> datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S');
'2013-09-17 08:06:17' 以上就是python中日期和时间格式化 输出的方法小结_python的详细内容,更多请关注Gxl网其它相关文章!
查看更多关于python中日期和时间格式化输出的方法小结_python的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did84249