程序源码如下:
#coding =utf-8
def vowels_count(string):
ret = 0
for c in string:
if c in "dskfhkfh":
ret +=1
return ret
s = "kjfhkjlf"
print vowels_count(s)
print range(len("hello world"))
在ubuntu下的eclipse+pydev环境下,会在第10行,即
print vowels_count(s)
处提示有错。错误信息为(这个错误信息是显示在行号前):
Encountered "vowels_count" at line 10, column 7. Was expecting one of: <NEWLINE> ... "(" ...
"[" ... ";" ... "," ... "." ... "+" ... "-" ... "*" ... "/" ... "//" ... "<<" ... ">>" ... "%" ... "^" ...
"|" ... "&" ... "=" ... ">" ... "<" ... "==" ... "<=" ... ">=" ... "!=" ... "+=" ... "-=" ... "*=" ...
"/=" ... "//=" ... "%=" ... "&=" ... "|=" ... "^=" ... "<<=" ... ">>=" ... "**=" ... "or" ... "and"
... "not" ... "is" ... "in" ... "if" ... ";" ... "," ...
但是run还会有正确结果
output:
5
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
怪我咯2017-04-17 13:39:26
既然能夠正常運行,那麼這只是 IDE 的 bug 而已(Python 是動態語言,因此 IDE 的靜態分析很難完全做對)。如果你嫌煩,可以不用功能過於強大的 IDE,或是關掉這種提示。
又看了一下,也有可能是強製程式碼風格的資訊(也就是程式碼風格問題)。