我正在尝试用 Python 制作一个程序,将我的闪存驱动器上的文件(字母 D:)复制到我硬盘驱动器上的一个文件夹中,但我收到了PermissionError: [Errno 13] Permission denied: 'D:'。
我的代码有问题的部分如下:
# Copy files to folder in current directory
def copy():
source = getsource()
if source != "failure":
copyfile(source, createfolder())
wait("Successfully backup up drive"
"\nPress 'Enter' to exit the program")
else:
wait("No USB drive was detected"
"\nPress 'Enter' to exit")
# Create a folder in current directory w/ date and time
def createfolder():
name = strftime("%a, %b %d, %Y, %H.%M.%S", gmtime())
dir_path = os.path.dirname(os.path.realpath(__file__))
new_folder = dir_path + "\\" …Run Code Online (Sandbox Code Playgroud)