for循环:语法错误:输入''期望EOF不匹配

时间:2013-05-15 19:49:02

标签: python jython

我正在使用jython 2.5.1和netbeans,

我有以下代码:

import csv
import pprint
import os

column=[]
mycsv = csv.reader(open('F:\lia1.csv'))
for row in mycsv:
    text = row[0].strip()

if text.isdigit():
    column.append(text[-4:])


out=' '.join(column)

f2=open('F:\somefile.txt','w')
f1=open("F:\xml1.txt","r") 

for item in out:
    try:
        text = f1.readline()
        text = text.replace("Keys1028","Keys"+str(item))
        f2.write(text)

我有以下错误:

 for item in out:
    ^
SyntaxError: mismatched input '' expecting EOF

如果我评论出来试试:我得到:

  for item in out:
    ^
SyntaxError: mismatched input '' expecting EOF

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我认为这与陈述的嵌套有关。

错误修正了:

with open("c:/whatever") as one_file:
    with open("c:/otherlocation") as other_file:
        pass  #  or do things

请参阅with keyword and jython 2.5.1