如题,刚进行了一系列读取excel处理数据的操作,现在想将得出的dataframe重新生成为xlsx文档,并在文件名末尾加上生成这个文档的系统时间,目前我用的生成代码如下(WS为编辑好的dataframe名称):
#生成最后的report文档
datestring = datetime.strftime(datetime.now(), '%Y%m%d-%H:%M:%S')
WS.to_excel(excel_writer=r"C:/Users/DD/Desktop/Python/Testpro/{0}".format('upload_template' + datestring + '.xlsx'))
执行后会报错:
OSError: [Errno 22] Invalid argument: 'C:/Users/DD/Desktop/Python/Testpro/_upload_template20190124-10:10:30.xlsx'
请问要如何才能实现加入系统日期到文件名的操作呢?