小编ACa*_*lza的帖子

python 中的函数注释给出错误?

所以我做了一个函数,并想为其添加注释,但编译器一直给我一个错误:

def square_root(x:number, eps:number) -> float:
    pass
Run Code Online (Sandbox Code Playgroud)

编译器返回如下:

  File "/Users/albertcalzaretto/Google Drive/CSC148H1/e1/e1a.py", line 1
    def square_root(x, eps) -> float:
                            ^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)

我从未使用过函数注释,并且阅读了一些有关它的资料,并且我不认为我所做的事情是错误的。

python annotations function

5
推荐指数
1
解决办法
4477
查看次数

标签 统计

annotations ×1

function ×1

python ×1