作者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
1F:→ os653:IndentationError是指你排版错误了,python对缩排很敏感的 12/30 16:52
2F:→ os653:可能是你那行里有混杂tab跟空白所造成的 12/30 16:55
4F:→ os653:要找错直接把错误讯息丢给google就可以了,不用查字典 12/30 17:03
5F:→ windker:调了一下untabify region突然就能RUN了,不过还是感谢回答 12/30 18:42