Created
May 19, 2017 09:02
-
-
Save Everfighting/f69cac5cf7ba74e12402675f8522341e to your computer and use it in GitHub Desktop.
datetime和xlwt结合的相关操作
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from datetime import datetime | |
| import xlwt | |
| workbook = xlwt.Workbook() | |
| worksheet = workbook.add_sheet('sheet1',cell_overwrite_ok=True) | |
| jy_ts = datetime.strptime(jy_dt, '%Y-%m-%d') | |
| FIXED_COLS = ('统计日期', '星期', '月份') | |
| for i, val in enumerate(FIXED_COLS): | |
| worksheet.write(0, i, val) | |
| worksheet.write(1, 0, jy_ts.strftime('%Y-%m-%d')) | |
| worksheet.write(1, 1, jy_ts.isoweekday()) | |
| worksheet.write(1, 2, jy_ts.strftime('%m')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment