小编dea*_*ous的帖子

“AttributeError: 'Turtle' 对象没有属性 'colormode'” 尽管 Turtle.py 具有 colormode 属性

我尝试在此站点上运行使用 Turtle 库的代码,如下所示,

import turtle
import random

def main():
    tList = []
    head = 0
    numTurtles = 10
    wn = turtle.Screen()
    wn.setup(500,500)
    for i in range(numTurtles):
        nt = turtle.Turtle()   # Make a new turtle, initialize values
        nt.setheading(head)
        nt.pensize(2)
        nt.color(random.randrange(256),random.randrange(256),random.randrange(256))
        nt.speed(10)
        wn.tracer(30,0)
        tList.append(nt)       # Add the new turtle to the list
        head = head + 360/numTurtles

    for i in range(100):
        moveTurtles(tList,15,i)

    w = tList[0]
    w.up()
    w.goto(0,40)
    w.write("How to Think Like a ",True,"center","40pt Bold")
    w.goto(0,-35)
    w.write("Computer Scientist",True,"center","40pt Bold")

def moveTurtles(turtleList,dist,angle): …
Run Code Online (Sandbox Code Playgroud)

python error-handling attributes

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

attributes ×1

error-handling ×1

python ×1