time
# 测试时间戳和时间元组
import time
def main():
# 时间戳
testTime = time.time();
# 时间元组
time_tuple = time.localtime(testTime);
print("当前时间为 : {}".format(time.asctime()));
print("我是时间戳 : {}".format(testTime));
print("我是时间元组 : {}".format(str(time_tuple)));
print("时间元组格式化 转换为年月日时分秒 : {}".format(time.strftime("%Y-%m-%d %H:%M:%S",time_tuple)));
print("时间元组格式化 转换为日期 : {}".format(time.strftime("%F",time_tuple)));
print("时间元组格式化 转换为时间 : {}".format(time.strftime("%T",time_tuple)));
if __name__ == '__main__':
main();
calendar
import calendar
def main():
# 输出2021年3月的日历 calendar可以方便的实现整体的日历计算 具体方法自行百度
cal = calendar.month(2021,3);
print(cal);
if __name__ == '__main__':
main();
datetime这个用的挺多的,方法自行百度
from datetime import date,datetime
def main():
print("最小日期:{},最大日期:{},日期单位:{}".format(date.min,date.max,date.resolution))
print("今天的日期是:{}".format(date.today()))
if __name__ == '__main__':
main();