可以在保存文件时使用 datetime
模块获取当前系统时间并拼接到文件名中。示例代码如下:
import datetime
from openpyxl import Workbook#Create a workbook
wb = Workbook()
#Get current time
now = datetime.datetime.now()
#Create a file name with current date and time
file_name = 'example_' + now.strftime("%Y-%m-%d %H-%M-%S") + '