使用其他名称复制文件

时间:2014-01-05 03:37:11

标签: python

我想将/local/mnt/workspace/user/Automation/swbuild/board/test_new.html复制为/local/mnt/workspace/user/Automation/sw_admin/reports/board/test.html,如果它已经存在则覆盖test.html ..是否有内置的python复制命令来执行此操作?

/local/mnt/workspace/user/Automation/swbuild/board/test_new.html
/local/mnt/workspace/user/Automation/sw_admin/reports/board/test.html

1 个答案:

答案 0 :(得分:1)

使用shutil.copy

import shutil
shutil.copy('/local/mnt/workspace/user/Automation/swbuild/board/test_new.html',
            '/local/mnt/workspace/user/Automation/sw_admin/reports/board/test.html')