gpt4 book ai didi

python - 如何将文件复制到 Python 脚本中的特定文件夹?

转载 作者:太空狗 更新时间:2023-10-29 21:20:38 24 4
gpt4 key购买 nike

<分区>

我有一个文件的路径存储在一个变量(比方说)filePath 中。我想将该特定文件复制到 Python 脚本中的另一个特定文件夹。

我试过了

folderPath = (os.getcwd() + "/folder_name/") #to get the path of the folder
shutil.copyfile(filePath, folderPath)

但是我得到一个错误IOError: [Errno 21] Is a directory

我该如何解决这个问题?

我的问题似乎与 How do I copy a file in python? 重复.但实际上,我想将文件复制到文件夹/目录,而该问题的大多数答案都提到将一个文件复制到另一个文件

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com