编写python脚本将字符串20221111转换为xlrd模块可识别的时间格式
以下是将字符串“2022/11/11”转换为xlrd模块可识别的时间格式的Python脚本:
import datetime
import xlrd
date_string = "2022/11/11"
date_obj = datetime.datetime.strptime(date_string, "%Y/%m/%d")
excel_date = xlrd.xldate.xldate_from_datetime_tuple(date_obj.timetuple(), 0)
print(excel_date)
运行此脚本将输出Excel日期格式的时间值,即浮点数。这个值可以用于xlrd模块的日期相关函数中。
原文地址: http://www.cveoy.top/t/topic/mYZ 著作权归作者所有。请勿转载和采集!