python - 如何清除“唯一 ID 为 1”和“FileNotFoundError”?
问题描述
运行代码时卡住了。下面显示的文件路径是显示输出的路径,即我正在重命名它。现在,我无法获得输出。
The unique id is 1
Traceback (most recent call last):
File "F:\ISRO\S_data\codes\Auto.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.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
解决方案
尝试通过将 an 附加r
到以下格式的字符串输入路径来获取原始格式的输入路径:
os.rename(r"C:\\Users\\finol\\Desktop\\ISRO\\Final Program\\OVERVIEW.OUT",
str(uniqueid[a][0]))
我有linux系统,所以我无法在我自己的系统上复制问题,但这应该可以。您也可以更改\\
以/
查看它是否有效。
推荐阅读
- http - 如何在 IIS 10 上允许 LINK 和 UNLINK
- python - 将“ObservedDict”转换为自定义对象(文本中包含的对象的数据)[Python]
- node.js - 无法将项目推送到 Heroku
- javascript - Jqgrid edittype : select editoptions: dataUrl 没有被调用来填充数据
- javascript - 如何使用 useRef 挂钩访问数据属性值?
- python - 在精神病学中使用顺序 ITI 随机化图像呈现
- swift - Localizable.strings 在列表中不起作用
- python - CMakeLists.txt:2 处的 CMake 错误
: 找不到 CMAKE_Fortran_COMPILER - python - Pandas:遍历行,添加和减去日期,根据行值将这些日期附加到新列
- qt - Qt.createComponent() 在动态绑定时会导致后面的“Object has a QQmlContext”错误