python - ubuntu下eclipse+pydev报错
高洛峰
高洛峰 2017-04-17 13:37:26
0
1
548

程序源码如下:

#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]

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(1)
刘奇

Since it can run normally, then this is just a bug of the IDE (Python is a dynamic language, so it is difficult for the IDE's static analysis to be completely correct). If you find it annoying, you can avoid using an overly powerful IDE or turn off this prompt.

Looking at it again, it may also be information about mandatory coding style (that is, coding style issues).

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template