PermissionError:WinError 32-在编辑txt文件时

时间:2019-03-06 19:21:27

标签: python-3.x

在我看来,这一切都可以正常工作。尝试替换文本文件中的行时出现此错误。

PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'accuracy.txt' -> 'accuracy.txt.bak'

代码:

with open("accuracy.txt","a") as file:
    for line in fileinput.FileInput("accuracy.txt", inplace=1):
    line=line.replace(old_entry,new_entry)

0 个答案:

没有答案