代码有问题(将 datetime.strftime wehn 导出数据框添加到新 excel 的名称路径)
Trouble with code ( adding datetime.strftime wehn exporting data frame to the name path of new excel )
在将数据框导出到 excel 时,我一直在尝试将日期添加到文件名中。但不是创建 excel 文件,而是搜索具有该名称的文件而不是创建具有该名称的文件。
'''python
datestring= datetime.strftime(datetime.now(),'%m/%d/%Y')
export_excel=df_vacias.to_excel(r"the path {0}".format("vacias_"
datestring +'.xlsx',index=None, header=True))
错误
self.fp = io.open(file, filemode)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\(the user)\Desktop\vacias_09/19/2019.xlsx'
我希望创建这个文件'C:\Users\(the user)\Desktop\vacias_09/19/2019.xlsx'
就像许多特殊字符一样,/
字符也不允许出现在 Windows 中的文件或文件夹名称中。我认为那是你的问题。
在将数据框导出到 excel 时,我一直在尝试将日期添加到文件名中。但不是创建 excel 文件,而是搜索具有该名称的文件而不是创建具有该名称的文件。
'''python
datestring= datetime.strftime(datetime.now(),'%m/%d/%Y')
export_excel=df_vacias.to_excel(r"the path {0}".format("vacias_"
datestring +'.xlsx',index=None, header=True))
错误
self.fp = io.open(file, filemode)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\(the user)\Desktop\vacias_09/19/2019.xlsx'
我希望创建这个文件'C:\Users\(the user)\Desktop\vacias_09/19/2019.xlsx'
就像许多特殊字符一样,/
字符也不允许出现在 Windows 中的文件或文件夹名称中。我认为那是你的问题。