在运行代码时会卡住。下面显示的文件路径是显示输出的路径,即我正在重命名。现在,我无法获得输出。
The unique id is 1
Traceback (most recent call last):
File "F:ISROS_datacodesAuto.py", line 390, in <module>
os.rename("C:\Users\finol\Desktop\ISRO\Final Program\OVERVIEW.OUT", str(uniqueid[a][0])) ##The output file is renames with the uniqueid
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\Users\finol\Desktop\ISRO\Final Program\OVERVIEW.OUT' -> '1'
'''
And this is the part of the code
导入OS
os.rename("C:\Users\finol\Desktop\ISRO\Final Program\OVERVIEW.OUT",
str(uniqueid[a][0])) ##The output file is renames with the uniqueid
import shutil
shutil.move(str(uniqueid[a][0]),
"C:\Users\finol\Desktop\ISRO\Final Program\OUTPUT\") ##The output file is moved to a seperate directory
a = a + 1
尝试通过将r
附加到字符串输入路径以下格式:
os.rename(r"C:\Users\finol\Desktop\ISRO\Final Program\OVERVIEW.OUT",
str(uniqueid[a][0]))
我有Linux系统,因此我无法在自己的系统上复制问题,但这应该起作用。您还可以将\
更改为/
,以查看它是否有效。