python - 简单的Python-3程序中的无效语法错误

标签 python syntax python-3.x syntax-error

from TurtleWorld import *
import math

bob = Turtle()
print(bob)

draw_circle(turtle, r):
    d = r*2
    c = d*math.pi
    degrees = 360/25
    length = c // 25
    for i in range(25):
        fd(turtle, length)
        rt(turtle, degrees)

draw_circle(bob, 25)

wait_for_user()

第7行的问题:

draw_circle(turtle, r):



编译器仅告诉我语法错误,并在命令行高亮显示冒号。
该行的结尾。
我确定我缺少一些简单的东西,但是代码对我来说似乎正确。

最佳答案

在python中,我们使用def关键字定义函数。

def draw_circle(turtle, r):
    # ...

关于python - 简单的Python-3程序中的无效语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3471165/

相关文章:

python - 如何在 Django 中获取 group by 中的额外列?

python - 在 Python 中根据函数名拆分 SQL 语句但保留分隔符

python - 如何在 PyQt 中将键盘焦点带到 QTextEdit 上?

generics - 实现不只是 impl Foo<T> 是否有技术原因?

c++ - 以循环方式使用来自另一个类的 typedef

assembly - 冒号 : mean in x86 assembly GAS syntax as in %ds:(%bx)? 是什么意思

python - @properties 装饰器是否缓存结果?

python - Windows arcgis 子目录上的导入错误 : No module name PyPdf2 python 2. 7.13

python - 从python中的max函数获取有线结果

python - paramiko.exec_command() 未执行并返回 "Extra params found in CLI"