찾다

 >  Q&A  >  본문

python - ubuntu下eclipse+pydev报错

程序源码如下:

1

2

3

4

5

6

7

8

9

10

11

12

<code>#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"))

</code>

在ubuntu下的eclipse+pydev环境下,会在第10行,即

1

2

<code>print vowels_count(s)

</code>

处提示有错。错误信息为(这个错误信息是显示在行号前):

1

2

3

4

5

6

<code>Encountered "vowels_count" at line 10, column 7. Was expecting one of:     <NEWLINE> ...     "(" ...    

 "[" ...     ";" ...     "," ...     "." ...     "+" ...     "-" ...     "*" ...     "/" ...     "//" ...     "<<" ...     ">>" ...     "%" ...     "^" ...    

 "|" ...     "&" ...     "=" ...     ">" ...     "<" ...     "==" ...     "<=" ...     ">=" ...     "!=" ...     "+=" ...     "-=" ...     "*=" ...    

 "/=" ...     "//=" ...     "%=" ...     "&=" ...     "|=" ...     "^=" ...     "<<=" ...     ">>=" ...     "**=" ...     "or" ...     "and"

 ...     "not" ...     "is" ...     "in" ...     "if" ...     ";" ...     "," ...

</code>

但是run还会有正确结果

1

2

3

4

5

<code>output:

5

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

 

</code>

高洛峰高洛峰2881일 전622

모든 응답(1)나는 대답할 것이다

  • 怪我咯

    怪我咯2017-04-17 13:39:26

    既然能够正常运行,那么这只是 IDE 的 bug 而已(Python 是动态语言,因此 IDE 的静态分析很难完全做对)。如果你嫌烦,可以不用功能过于强大的 IDE,或者关掉这种提示。

    又看了一下,也有可能是强制代码风格的信息(也就是代码风格问题)。

    회신하다
    0
  • 취소회신하다