IOError:[Errno 22]调用的模式(“rb”)或文件名无效shutil.复制()

2024-04-26 05:03:48 发布

您现在位置:Python中文网/ 问答频道 /正文

但我在另一个程序中遇到了另一个问题。在

代码如下:

import os
import shutil
def copy_music():
    file_list = os.listdir(r"C:\Users\hp\Downloads")
    saved_path = os.getcwd()
    print("current working directory is "+saved_path)
    os.chdir(r"C:\Users\hp\Downloads")
    for file_name in file_list:
        test = file_name.endswith('.mp3')
        if test == True:
            shutil.copy(file_name, 'c:\Users\hp\music')
    os.chdir(saved_path)
    print('all the mp3 files are successfully copied to your destination')
copy_music()

以下是错误消息:


^{pr2}$

Tags: pathnameimportosdownloadsmusicuserslist

热门问题