作者windker (windker)
看板Python
標題[問題] 請問error:inconsistent indentation detected??
時間Thu Dec 30 15:43:50 2010
#字串1abc2xyz3mno4ijk
#想要得到數字間字母的bigram
#目標是 S1=['ab', 'bc'] S2=['xy', 'yz'] S3=['mn', 'no'] S4=['ij', 'jk']
big=['1', 'a', 'b', 'c', '2', 'x', 'y', 'z', '3', 'm', 'n', 'o', '4', 'i',
'j', 'k']
L1=[(0, 's1'), (4, 's2'), (8, 's3'), (12, 's4')]
L2=[0, 4, 8, 12]
S1,S2,S3,S4=[],[],[],[]
for i in range(4):
if L1[i][1]=='s1':
for j in range(L2[i]+1,L2[i+1]-1):
print i,j
S1.append(big[j]+big[j+1])
print S1
elif L1[i][1]=='s2':
for j in range(L2[i]+1,L2[i+1]-1):
print i,j
print big[j]+big[j+1]
#1 S2.append(big[j]+big[j+1])
一旦拿掉#1就會出現error:inconsisten indentation detected,
google了一下indentation中文叫縮進,但還是不懂怎麼解,請問
有人知道如何解嗎,感恩
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.32.128.82
→ os653:IndentationError是指你排版錯誤了,python對縮排很敏感的 12/30 16:52
→ os653:可能是你那行裡有混雜tab跟空白所造成的 12/30 16:55
→ os653:要找錯直接把錯誤訊息丟給google就可以了,不用查字典 12/30 17:03
→ windker:調了一下untabify region突然就能RUN了,不過還是感謝回答 12/30 18:42