[英]How do I copy all folder contents from one location to another location in Python?
I have been trying to make a python file that will copy contents from one folder to another.我一直在尝试制作一个 python 文件,它将内容从一个文件夹复制到另一个文件夹。 I would like it to work on any Windows system that I run it on.
我希望它能在我运行它的任何 Windows 系统上运行。 It must copy ALL things.
它必须复制所有东西。
i need solution to this problem.我需要解决这个问题。
You can use the copytree function of the shutil library:可以使用shutil库的copytree function :
import shutil
source_folder = "C:\\Users\\user1\\source_folder"
destination_folder = "C:\\Users\\user1\\destination_folder"
# Copy the contents of the source folder to the destination folder
shutil.copytree(source_folder, destination_folder)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.