2012-07-15 168 views
0

我的休息有什麼問題?我不明白爲什麼它說我打破這種無效的語法當我編譯的代碼break語法錯誤:語法錯誤

for index, (start, end) in enumerate(searchPFAM(fname)):    
    with open('output_'+uniprotID+'-%s.txt' % index,'w') as fileinput: 
     print start, end 
     for item in lookup[uniprotID]: 
      item, start, end = map(int, (item, start, end)) #make sure that all value is int 
      if start <= item <= end: 
       print item 
       result = str(item - start) 
       fileinput.write(">{0} | at position {1} \n".format(uniprotID, result)) 
       #text = fileinput.write(''.join(makeList[start-1:end])) 
       textwrap.fill(''.join(makeList[start-1:end],width = 60) 
       break 
      else: 
       fileinput.write(">{0} | N/A\n".format(uniprotID)) 
       #text = fileinput.write(''.join(makeList[start-1:end])) 
       textwrap.fill(''.join(makeList[start-1:end],width = 60) 
+1

它是否是製表符敏感的,您的else語句是否符合for語句?我知道py對此很敏感。 – 2012-07-15 21:55:48

+0

@MikeS。好趕上謝謝 – 2012-07-15 22:01:27

+0

如果這有幫助,我應該發佈一個答案嗎? – 2012-07-15 22:03:40

回答

5

你缺少在這一行一個右括號:

textwrap.fill(''.join(makeList[start-1:end],width = 60) 
#   ^ ^       ^

它應該是這樣的:

textwrap.fill(''.join(makeList[start-1:end]),width = 60) 
+0

好趕上..謝謝,但它應該是括號後結束] – 2012-07-15 21:57:50

+0

是的,謝謝我修好了。 – 2012-07-15 21:58:12

1

這是上一行缺少的右括號。

+0

好趕上謝謝你:) – 2012-07-15 21:58:07