我想在我的计算机上的L:驱动器中的一个名为11109的文件夹中迭代一些文件。这是我的脚本:
for filename in os.listdir('L:\11109'):
print(filename.split('-')[1])
但是,错误消息返回为:
File "L:/OMIZ/rando.py", line 12, in <module>
for filename in os.listdir('L:\11109'):
FileNotFoundError: [WinError 3] The system cannot find the path specified:
'L:I09'
读取L:\11109很好,但是错误消息说指定的路径是L:I09
您需要使用原始字符串或转义反斜杠,否则
\111
将解析为I
:要解决这个问题,你可以这样做
相关问题 更多 >
编程相关推荐