Python Day12 作业

# 1、通用文件copy工具实现
import os
import time

# f_path = input('输入要copy的文件目录')
# c_fpath = input('输入要copy到的目录')
# if os.path.exists(f_path):
# with open(f_path, mode='rb')as f, open(c_fpath, mode='wb')as f1:
# res = f.read()
# f1.write(res)
# else:
# print('路径不存在')
# 2、基于seek控制指针移动,测试r+、w+、a+模式下的读写内容
# with open('a.txt', mode='wb+', )as f:
# f.write('aaa与你'.encode('utf-8'))
# f.seek(6)
# res = f.read().decode('utf-8')
# print(res)
# with open('a.txt', mode='ab+', )as f:
# f.write('ddddidid'.encode('utf-8'))
# f.seek(6)
# res = f.read().decode('utf-8')
# print(res)
# 3、tail -f access.log程序实现
# with open('b.txt',mode='rb')as f:
# f.seek(0, 2)
# while True:
# log = f.readline()
# if len(log)==0:
# time.sleep(0.5)
# else:
# print(log.decode('utf-8'),end='')

猜你喜欢

转载自www.cnblogs.com/AaronY/p/12508197.html