fromdatetimeimportdatetime# 获取当前日期和时间current_datetime=datetime.now()# 提取年、月、日current_year=current_datetime.year current_month=current_datetime.month current_day=current_datetime.day# 输出结果print(f"当前日期为:{current_year}年{current_month}月{current_day}日") 1. 2. 3. 4. 5....
1465728983.45 #自1970年1月1日午夜 1. 2. 3. 4. 5. 6. 7. 8. 获取当前时间:经过转换的格式 import time localtime = time.localtime(time.time()) print localtime #输出 time.struct_time(tm_year=2016, tm_mon=6, tm_mday=12, tm_hour=18, tm_min=58, tm_sec=55, tm_wday=6, tm_y...
day=today.day# 输出当前日期print("当前日期:",today)print("年:",year)print("月:",month)print("日:",day)# 判断是否为闰年is_leap_year=Falseifyear%4==0and(year%100!=0oryear%400==0):is_leap_year=Trueifis_leap_year:print(year,"年是闰年。")else:print(year,"年不是闰年。")# 计算...