2017-10-11 104 views
0

我正在关注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

你总有count = 1

改变这一行:

count = + 1 

count += 1