3.时间函数 time(时间函数设置)

1.time.time()返回当前时间的时间戳

2.time.sleep(secs):使程序暂停 secs 秒

3. 按照 "年-月-日 时:分:秒" 的格式输出当前时间
current_time = time.strftime("%Y-%m-%d %H:%M:%S")
print(f"当前时间: {current_time}")

4.文本转换成对象
time_str = "2023-09-15 14:30:00"
time_obj = time.strptime(time_str, "%Y-%m-%d %H:%M:%S")
print(f"解析后的时间对象: {time_obj}")
原文链接:,转发请注明来源!