Python自带的time模块不需要通过pip安装,可以直接在Python脚本中导入使用。以下是time模块的基本用法:
import time获取当前时间戳current_time = time.time()print("当前时间戳为:", current_time)将时间戳转换为本地时间元组local_time = time.localtime(current_time)print("本地时间:", local_time)将时间元组转换为可读时间字符串readable_time = time.asctime(local_time)print("可读时间:", readable_time)暂停执行一段时间time.sleep(5) 暂停5秒

