首页 > 解决方案 > 如何在python中修复“找不到此类文件错误”

问题描述

我正在尝试从字节文件中提取特征。

通过打开文件时

with open('byteFiles/'+file,"r") as fp:
    ...

我收到错误“Nosuchfilefound”。我已经检查过该文件是否存在,甚至尝试在字节文件r之前放置

with open(r'byteFiles/'+file,"r") as fp:
    ...

但我仍然无法修复它。

with open('byteFiles/'+file,"r") as fp:
    lines=""
    for line in fp:
        a=line.rstrip().split(" ")[1:]
            b=' '.join(a)
            b=b+"\n"
            text_file.write(b)
            fp.close()
            os.remove('byteFiles/'+file)
        text_file.close()

我收到错误消息:

FileNotFoundError:[Errno 2] 没有这样的文件或目录:'byteFiles/01azqd4InC7m9JpocGv5'

标签: python-3.xjupyter-notebook

解决方案


推荐阅读