标签:color 结果 div alt day class 字符 com col
from datetime import datetime dt=datetime.now() print(‘当前时间为:‘,dt) dtu=datetime.utcnow() print(‘国际标准时间为:‘,dtu) dtt=datetime(2017,5,23,12,20) print("设置时间为:",dtt)
运行结果:
print(‘------将以下字符串转换成datetime类型------‘) t=datetime.strptime(‘2017/9/30‘,‘%Y/%m/%d‘) print(t) t=datetime.strptime(‘2017年9月30日星期六‘,‘%Y年%m月%d日星期六‘) print(t) t=datetime.strptime(‘2017年9月30日星期六8时42分24秒‘,‘%Y年%m月%d日星期六%H时%M分%S秒‘) print(t) t=datetime.strptime(‘9/30/2017‘,‘%m/%d/%Y‘) print(t) t=datetime.strptime(‘9/30/2017 8:42:50‘,‘%m/%d/%Y %H:%M:%S‘) print(t)
运行结果:
dt1=dt.strftime(‘%Y年%m月%d日星期%w,%H时%M分%S秒‘) print(dt1) dt2=dt.strftime(‘%A,%B %d,%Y‘) print(dt2) dt3=dt.strftime(‘%m/%d/%Y %H:%M:%S %p‘) print(dt3) dt4=dt.strftime(‘%B %d,%Y‘) print(dt4)
dt5=dt.strftime(‘今天是%Y年%m月%d日‘) print(dt5) dt6=dt.strftime(‘今天是这周的第%w天‘) print(dt6) dt7=dt.strftime(‘今天是今年的第%j天‘) print(dt7) dt8=dt.strftime(‘今周是今年的第%W周‘) print(dt8) dt9=dt.strftime(‘今天是当月的第%d天‘) print(dt9)
标签:color 结果 div alt day class 字符 com col
原文地址:http://www.cnblogs.com/Naiky/p/7618237.html