#1、通用文件copy工具实现
# file1=input('源文件路径>>: ').strip()
# file2=input('源文件路径>>: ').strip()
# with open(r'{}'.format(file1),mode='rb') as f1,\
# open(r'{}'.format(file2),mode='wb') as f2:
# for line in f1:
# f2.write(line)
#2、基于seek控制指针移动,测试r+、w+、a+模式下的读写内容
# with open('d.txt',mode='r+',encoding='utf-8') as f:
# print(f.read())
# f.seek(9,0)
# print(f.tell())
# f.write("11") #写入两个字节
# f.seek(9, 0) #回到写入前
# print(f.read()) #读出写入内容
# with open('d.txt',mode='w+',encoding='utf-8') as f:
# print(f.read())
# f.seek(9,0)
# print(f.tell())
# res=f.write("11")
# print(f.read()) #从11后面开始读不到内容
# with open('d.txt',mode='a+',encoding='utf-8') as f:
# print(f.read()) #读不出内容
# print(f.tell()) #指针在末尾的9
# f.write("11") #写入两个字节
# f.seek(9, 0) #回到写入前
# print(f.read()) #读出写入内容
#3、tail -f access.log程序实现
cmd=input("请输入信息:")
with open('db.txt',mode='a+',encoding='utf-8')as f:
f.write(cmd)
f.seek(0,0)
print(f.read())