当前位置 : 主页 > 编程语言 > python >

python文件切割

来源:互联网 收集:自由互联 发布时间:2022-06-21
fopen = open('cleanding.csv', 'r') diff_line = fopen.readlines() line_list = [] for line in diff_line: line_list.append(line[:len(line)-1]) print(line_list) diff_match_split = [line_list[i:i + 100] for i in range(0, len(line_list), 100)] # 将
fopen = open('cleanding.csv', 'r')
diff_line = fopen.readlines()

line_list = []
for line in diff_line:
line_list.append(line[:len(line)-1])
print(line_list)

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

# 将文件切割
for i, j in zip(range(0, 11), range(0, 11)):
with open('wilson_split%d.csv' % j, 'w+') as temp:
for line in diff_match_split[i]:
temp.write(line+'\n')

将一个文件切割成10个文件


上一篇:python中URL常见的header
下一篇:没有了
网友评论