我在挂载的文件夹中有一个现有文件,我通过以下方式验证
os.path.isfile(config.inpath + file)
True
但以下内容返回一个文件未发现错误
os.remove(config.inpath + file)
*** FileNotFoundError: [Errno 2] No such file or directory:
也
os.system('rm ' + config.inpath + file)
不行。但是,我可以从终端中删除该文件。
知道为什么这在 python 中不起作用吗?
编辑:
我不知道这是否有帮助,但这将是确切的错误消息
FileNotFoundError: [Errno 2] No such file or directory: '/home/operations/mnt/CustomerFolder/TESTSSTEM/filename.xml'
不幸
os.remove(os.path.join(config.inpfad, file))
FileNotFoundError: [Errno 2] No such file or directory:
也不起作用。
该文件也不是符号链接。
感谢所有帮助我找到错误的人。
实际上
os.system('rm -f ' + config.inpath + file)
工作正常。