标签:today 2017年 中文 png 如何 技术 blog str class
1.
>>> from datetime import datetime >>> datetime.now() datetime.datetime(2017, 10, 1, 19, 25, 9, 835498) >>> datetime.utcnow() datetime.datetime(2017, 10, 1, 11, 25, 22, 523224) >>> datetime(2017,5,23,12,20) datetime.datetime(2017, 5, 23, 12, 20)
2.
from datetime import datetime a=datetime.strptime(‘2017/9/30‘,‘%Y/%m/%d‘) print(a) a1=datetime.strptime(‘2017年9月30日星期六‘,‘%Y年%m月%d日星期六‘) print(a1) a2=datetime.strptime(‘2017年9月30日星期六8时42分24秒‘,‘%Y年%m月%d日星期六%H时%M分%S秒‘) print(a2) a3=datetime.strptime(‘9/30/2017‘,‘%m/%d/%Y‘) print(a3) a4=datetime.strptime(‘9/30/2017 8:42:50‘,‘%m/%d/%Y %H:%M:%S‘) print(a4)
3.
from datetime import datetime dt=datetime(2017,10,1,10,3,43) a=dt.strtime(‘%Y年%m月%d日%A,%H时%M分%S秒‘) print(a) b=dt.strtime(‘%A,%B %d,%Y‘) print(b) c=dt.strtime(‘%m/%d/%Y %I:%M:%S%p‘) print(c) d=dt.strtime(‘%B %d,%Y‘) print(d)
4.
from datetime import datetime now=datetime(2017,9,30) a=now.strftime(‘today is %Y,%m,%d‘) print(a) b=now.strftime(‘today is the %w day of this week‘) print(b) c=now.strftime(‘today is the %j day of this year‘) print(c) d=now.strftime(‘this week is the %W week of this year‘) print(d) e=now.strftime(‘today is the %d day of this month‘) print(e)
第四个那个我输入中文会报错。embedded null byte。不知如何解决。
标签:today 2017年 中文 png 如何 技术 blog str class
原文地址:http://www.cnblogs.com/blackboardf/p/7617685.html