[問題] 請問error:inconsistent indentation detected??

看板Python作者 (windker)時間14年前 (2010/12/30 15:43), 編輯推噓0(005)
留言5則, 2人參與, 最新討論串1/1
#字串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

12/30 16:52, , 1F
IndentationError是指你排版錯誤了,python對縮排很敏感的
12/30 16:52, 1F

12/30 16:55, , 2F
可能是你那行裡有混雜tab跟空白所造成的
12/30 16:55, 2F

12/30 17:02, , 3F
http://0rz.tw/r0te6 這網址最後面有寫到你的錯誤
12/30 17:02, 3F

12/30 17:03, , 4F
要找錯直接把錯誤訊息丟給google就可以了,不用查字典
12/30 17:03, 4F

12/30 18:42, , 5F
調了一下untabify region突然就能RUN了,不過還是感謝回答
12/30 18:42, 5F
文章代碼(AID): #1D73WubH (Python)
文章代碼(AID): #1D73WubH (Python)