用Python拷贝文件的方式其实有很多,但个人觉得最简单、最直接的可能是这么两种:

 

方法一:借助操作系统中本身的拷贝命令

>>> import os
>>> os.system("xcopy C:\\1.txt D:")
C:\1.txt
1 File(s) copied
0

 

方法二:借助shutil模块来完成拷贝操作

>>> import shutil
>>> shutil.copyfile('C:\\1.txt', 'D:\\1.txt')
>>>

 

 

原文:https://blog.csdn.net/Jerry_1126/article/details/86602517

相关文章:

  • 2021-12-11
  • 2022-12-23
  • 2022-12-23
  • 2021-11-11
猜你喜欢
  • 2022-02-11
  • 2022-12-23
  • 2022-12-23
  • 2022-01-13
  • 2022-12-23
  • 2021-11-08
相关资源
相似解决方案