12----我是作业

1、通用文件copy工具实现
src_file = input('path:').strip()
tag_file = input('path:').strip()
with open(r'{}'.format(src_file),'rb') as f,\
     open(r'{}'.format(tag_file),'wb') as f1:
#     循环读取文件,防止文件过大,内存溢出
# 方式一
#     for line in
#       f1.write(line)
# 方式二
    while True:
        res = f.read(1024)
        if res == b'':
            break
        else:
            f1.write(res)

2、基于seek控制指针移动,测试r+、w+、a+模式下的读写内容

猜你喜欢

转载自www.cnblogs.com/Kathrine/p/12506019.html
今日推荐