美文网首页
Python导出到excel,时间格式处理(2019-02-19

Python导出到excel,时间格式处理(2019-02-19

作者: sean5000 | 来源:发表于2019-02-19 10:51 被阅读0次

    Entering a Date into a Cell

    import xlwt

    import datetime

    workbook = xlwt.Workbook()

    worksheet = workbook.add_sheet('My Sheet')

    style = xlwt.XFStyle()

    style.num_format_str = 'M/D/YY'

    # Other options: D-MMM-YY, D-MMM, MMM-YY, h:mm, h:mm:ss, h:mm, h:mm:ss, M/D/YY h:mm, mm:ss, [h]:mm:ss, mm:ss.0

    worksheet.write(0, 0, datetime.datetime.now(), style)

    workbook.save('Excel_Workbook.xls')

    相关文章

      网友评论

          本文标题:Python导出到excel,时间格式处理(2019-02-19

          本文链接:https://www.haomeiwen.com/subject/rudxyqtx.html