2017-10-11 83 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 
相關問題