"""
生成日期 1990 - 2100
"""
from openpyxl import Workbook
json_list = []
read_file_path = r"你要保存的文件"
with open(read_file_path, 'r', encoding='utf-8') as file:
workbook = Workbook()
ws = workbook.active
headers = ['year', 'month', 'year_month']
year = 1990
ws.append(headers)
while year <= 2100:
year_month = 0
month = 1
while month <= 12:
year_month = (year * 100) + month
ws.append([year, month, year_month])
print("写入日期:", year_month)
month += 1
year += 1
# 写入excel
workbook.save(filename=read_file_path)
自动生成日期范围并保存到excel中
最新推荐文章于 2024-08-09 14:22:03 发布