if __name__ == "__main__":
path="E:\\download\\测试数据.txt"
with open(path,"rb") as fp:
# 设置分割的大小,单位k
size=300
size=size*1024
# 开始位置
start=0
# 读取的最终位置
end=0
# 计数器
i=1
byte=b"0"
while byte!=b"":
# 设置指针位置,主要是为了查找指针后面\n的位置,这个操作简称为“寻值”
fp.seek(end+size,0)
byte=fp.read(1)
i+=1
# 寻值
while byte!=b"\n" and byte!=b"":
byte=fp.read(1)
end=fp.tell()
# 存入文件
with open("E:\\download\\a\\1\\"+str(i*1)+".txt","wb") as fp1:
fp.seek(start,0)
fp1.write(fp.read(end-start))
start=end
