我跟着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()
答案 0 :(得分:0)
你总是count = 1
。
更改此行:
count = + 1
到
count += 1