上班打卡
第五天
python基础知识
1.日期和时间:
日期和时间
datetime模块为日期和时间处理同时提供了简单和复杂的方法。
支持日期和时间算法的同时,实现的重点放在更有效的处理和格式化输出
。
该模块还支持时区处理:
import time
from datetime import date
now=date.today()
print(now)
#设定时间
str1=now.strftime("%m-%d-%y. %d %b %Y is a %A on the %d day of %B.")
print(str1)
print(time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())))
print(time.strftime("%Y-%m-%d %H:%M:%S",time.localtime()))
测试结果:
2021-07-19
07-19-21. 19 Jul 2021 is a Monday on the 19 day of July.
2021-07-19 10:02:20
2021-07-19 10:02:20
今日一直在练题 明日更新