【发布时间】:2017-10-11 11:19:23
【问题描述】:
我正在关注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()
【问题讨论】:
标签: python-3.x text split