[英]Error in Python - Unexpected Indent
# Use the file name mbox-short.txt as the file name
fname = raw_input("Enter file name: ")
count = 0
avg = 0
fh = open(fname)
for line in fh:
if not line.startswith("X-DSPAM-Confidence:") :
continue
count = count + 1
pos = line.find(":")
new = float(line[pos+1:])
avg = avg + new
print "Done",count,avg
I get the following error for this code: 我收到此代码的以下错误:
line 11
IndentationError : unexpected indent
Please help me out. 请帮帮我。 This stuff may seem stupid to some but pardon me, I'm a noob. 这些东西对某些人可能看起来很愚蠢,但请原谅我,我是菜鸟。 Thanks in advance 提前致谢
Please make sure you are not indenting using Tab
and Space
at the same time. 请确保您不同时缩进使用Tab
和Space
。
If you mixing Tab
and Space
when indenting, python will be confused. 如果在缩进时混合使用Tab
和Space
,则python会感到困惑。 I good practice is to set your text editor's auto indentation to the same indentation you preferred. 我的最佳做法是将文本编辑器的自动缩进设置为您喜欢的缩进。 This way, in case you need to manually change indentation, your indentation will be consistent with those created by your text editor. 这样,如果您需要手动更改缩进,则缩进将与文本编辑器创建的缩进一致。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.