linux中python程序复制文件的代码实现

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux中python程序复制文件的代码实现相关的知识,希望对你有一定的参考价值。

#文件的复制1.py

def copy():

 file_read1 = open("/usr/bin/ls",mode="rb")#source文件

 file_write1 = open("/root/day3/new",mode="wb")#目标路径


 while True:

     data = file_read1.read(4096)

     if len(data) == 0:

         break

     file_write1.write(data)

 file_read1.close()

 file_write1.close()

 print("完成")

copy()

以上是关于linux中python程序复制文件的代码实现的主要内容,如果未能解决你的问题,请参考以下文章