2017-10-11 10 views
0

区切り文字付きのテキストファイルを区切って書き出すには、this tutorial hereに従うが、出力時には1つのファイルしか取得しない。これは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

あなたはallways count = 1があります。

変更この行:

count += 1 

count = + 1 

関連する問題