从分隔文本中分离并写入唯一文件
问题描述:
我正在关注this tutorial here来分隔并写出分隔文本文件,但只获得一个输出文件。这是一个python2 - > 3的问题?请帮助。从分隔文本中分离并写入唯一文件
filename = ('file path')
with open(filename) as Input:
op = ''
start = 0
count = 1
for x in Input.read().split("\n"):
if (x == 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'):
if (start == 1):
with open(str(count) + '.txt', 'w') as Output:
Output.write(op)
Output.close()
op = ''
count = + 1
else:
start = 1
Input.close()
答
你总有count = 1
。
改变这一行:
count = + 1
到
count += 1