import shutil
argetdir_path = 'D:\\Python\\code\\PyQt\\1_study.py'
Targetfile_path = 'D:\\Python\\code\\2_study.py'
shutil.copyfile(argetdir_path, Targetfile_path)
上面的代码是说把路径为D:\Python\code\PyQt\1_study.py的文件1_study.py复制到D:\Python\code\2_study.py的路径下面去,复制过来的文件叫2_study.py
本文介绍如何使用Python的shutil模块中的copyfile方法来复制文件。具体示例为将路径为D:PythoncodePyQt1_study.py的文件复制到D:Pythoncode目录下,并命名为2_study.py。
375

被折叠的 条评论
为什么被折叠?



