设置日期格式

 # 设置单元格格式
    # 日期所在的列
    datelist = [16, 17, 18]
    for row in range(2, rows3 + 1):
        for column in datelist:
            datevalue = ws.cell(row=row, column=column).value
            # datevalue = datevalue.replace('-','/')
            # print(datevalue)
            if datevalue == '':
                pass
            elif datevalue=='NaT':
                pass
            else:
                datevalueformat = datetime.datetime.strptime(datevalue, "%Y-%m-%d")

                ws.cell(row=row,column=column).value = datevalueformat
不考虑业务场景,一味的争执技术的高下,都是耍流氓。
原文地址:https://www.cnblogs.com/leoych/p/13389882.html