path='U:\rmarshallWork For Staff\ROB\_Downloads Folder\'
file='file.pdf'
newFileName=time.strftime('%Y-%m-%d_')+row[1]+time.strftime('_%H:%M:%S')+'.pdf'
newFolderLocation='U:\Company - do not alter\'
os.rename(path+file,newFolderLocation+newFileName)
当我跑步时,我得到:
>>> os.rename(path+file,newFolderLocation+newFileName)
OSError: [WinError 123] The filename, directory name, or volume label syntax is
incorrect: 'U:/Company - do not alter/2014-01-14_COMPANY NAME_13:55:23.pdf'
谁能看到语法错误?
Windows 文件名中不允许使用冒号 :.
The colon : is not allowed in Windows file names.
请参阅 MSDN 上的 命名文件、路径和命名空间
See Naming Files, Paths, and Namespaces on MSDN
这篇关于Python - os.rename() - OSError: [WinError 123]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何在 Python 中将货币字符串转换为浮点数?How do I convert a currency string to a floating point number in Python?(如何在 Python 中将货币字符串转换为浮点数?)
在 Pandas 中解析多索引 Excel 文件Parsing a Multi-Index Excel File in Pandas(在 Pandas 中解析多索引 Excel 文件)
pandas 时间序列 between_datetime 函数?pandas timeseries between_datetime function?( pandas 时间序列 between_datetime 函数?)
pandas 重新采样到每月的特定工作日pandas resample to specific weekday in month( pandas 重新采样到每月的特定工作日)
Python - 如何标准化时间序列数据Python - how to normalize time-series data(Python - 如何标准化时间序列数据)
statsmodels 使用 ARMA 模型进行预测statsmodels forecasting using ARMA model(statsmodels 使用 ARMA 模型进行预测)