目的
一个txt文档内容分成若干个txt文档,根据换行符来分开。
#coding:utf-8
def read_file(path):
with open(path) as f:
temp = f.read()
a = temp.split('\n')
b = []
for i in a:
b.append(i)
return b
def save_file(b):
w = len(b)
for j in range(w):
with open(str(j) + '.txt','w') as f:
f.write(b[j])
f.close()
def main():
b = read_file('base.txt')
save_file(b)
if __name__ == "__main__":
main()
网友评论