python 中实现文件的复制

发布时间 2023-03-22 21:32:31作者: 小鲨鱼2018

 

001、

(base) [root@PC1 test3]# ls               ## 测试数据及脚本
a.txt  test.py
(base) [root@PC1 test3]# cat test.py      ## 复制程序
import os
os.popen('cp a.txt b.txt')
(base) [root@PC1 test3]# python test.py   ## 执行程序
(base) [root@PC1 test3]# ls               ## 复制结果b.txt
a.txt  b.txt  test.py
(base) [root@PC1 test3]# md5sum a.txt b.txt     ## 验证结果
3b0332e02daabf31651a5a0d81ba830a  a.txt
3b0332e02daabf31651a5a0d81ba830a  b.txt