使用shutil.move时出现Python 3.8权限错误

使用shutil.move时出现Python 3.8权限错误,python,Python,我正在尝试编写一个python代码,该代码将监视特定文件夹中的任何“修改”事件,然后将行从源csv文件复制到目标csv文件 复制行后,我希望将源文件移动到存档文件夹,此时我会收到“Win32权限错误” 有人能帮忙吗 类处理程序(FileSystemEventHandler): 错误: PermissionError:[WinError 32]进程无法访问该文件,因为它正被另一个进程使用:将shutil.move()调用移到with语句外部是否有效?如果将shutil.move()移到with语句

我正在尝试编写一个python代码,该代码将监视特定文件夹中的任何“修改”事件,然后将行从源csv文件复制到目标csv文件

复制行后,我希望将源文件移动到存档文件夹,此时我会收到“Win32权限错误”

有人能帮忙吗

类处理程序(FileSystemEventHandler):

错误:
PermissionError:[WinError 32]进程无法访问该文件,因为它正被另一个进程使用:

shutil.move()调用移到with语句外部是否有效?如果将shutil.move()移到with语句外部,则会出现以下错误,出现异常:FileNotFoundError[Errno 2]没有这样的文件或目录:文件“C:\Users\paramm\Documents\Python\CSVcopy.py”,第41行,在打开(nsrc_文件,“r”)作为f_输入的on_事件中,打开(dst_文件,“a”,换行符=“”)作为f_输出:
@staticmethod
def on_any_event(event):
    if event.is_directory:
        return None

    elif event.event_type == 'modified':
        # Take any action here when a file is place in the Watch Folder.
        nsrc_file = event.src_path
        dst_file = "C:\\Users\\paramm\\Documents\\Python\\WB_output\\OE_2019.csv"
        archive_folder = "C:\\Users\\paramm\\Documents\\Python\\WB_archive"

        with open(nsrc_file, "r") as f_input, open(dst_file, "a", newline='') as f_output:
            csv_input = csv.reader(f_input)

            for row in csv_input:
                csv.writer(f_output).writerows(csv_input)

            shutil.move(nsrc_file, archive_folder)