在我看来,这一切都可以正常工作。尝试替换文本文件中的行时出现此错误。
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)