python将一个txt文件数据,按要求分开,写入多个txt文本中

# 读取总txt文件
open_diff = open('diff_match_image.txt', 'r')
diff_line = open_diff.readlines()

line_list = []
for line in diff_line:
    line_list.append(line)
# print(line_list)

#切分diff
diff_match_split = [line_list[i:i+100] for i in range(0,len(line_list),100)]

#将切分的写入多个txt中
for i,j in zip(range(0,13),range(0,13)):
    with open('diff_match%d.txt'% j,'w+') as temp:
        for line in diff_match_split [i]:
            temp.write(line)

 

    原文作者:浮生了大白
    原文地址: https://blog.csdn.net/qq_38640439/article/details/83084745
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞