31-拷贝文件
2018-07-30 本文已影响41人
凯茜的老爸
每次读取4K,读完为止:
src_fname = '/bin/ls'
dst_fname = '/root/ls'
src_fobj = open(src_fname, 'rb')
dst_fobj = open(dst_fname, 'wb')
while True:
data = src_fobj.read(4096)
if not data:
break
dst_fobj.write(data)
src_fobj.close()
dst_fobj.close()