合并行数
col = 4
创建新文件
nf = open("*.txt", "w+")
读取初始文件
with open("*.txt", "r") as f:
str = ""
for index, content in enumerate(f):
str += content.strip()
if (index+1) % col == 0:
# print(str)
nf.write(str + "\n")
str = ""
记得释放
nf.close()
col = 4
nf = open("*.txt", "w+")
with open("*.txt", "r") as f:
str = ""
for index, content in enumerate(f):
str += content.strip()
if (index+1) % col == 0:
# print(str)
nf.write(str + "\n")
str = ""
nf.close()