|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import turtle
import random
turtle.pencolor("green")
turtle.pensize(10)
turtle.pendown()
turtle.setup(800,600,30,30)
n = int(input())
for i in range(n):
a = random.randrange(0,256)
b = random.randrange(0,256)
c = random.randrange(0,256)
turtle.fillcolor(a,b,c)
turtle.begin_fill()
turtle.penup()
turtle.goto(0,-50*(i+1))
turtle.pendown()
turtle.circle(50*(i+1))
turtle.end_fill()
turtle.done()
hxdm这个报错显示
Traceback (most recent call last):
File "C:\Users\haishan\Desktop\test.py", line 12, in <module>
turtle.fillcolor(a,b,c)
File "<string>", line 8, in fillcolor
File "C:\Users\haishan\AppData\Local\Programs\Python\Python39\lib\turtle.py", line 2289, in fillcolor
color = self._colorstr(args)
File "C:\Users\haishan\AppData\Local\Programs\Python\Python39\lib\turtle.py", line 2697, in _colorstr
return self.screen._colorstr(args)
File "C:\Users\haishan\AppData\Local\Programs\Python\Python39\lib\turtle.py", line 1167, in _colorstr
raise TurtleGraphicsError("bad color sequence: %s" % str(color))
turtle.TurtleGraphicsError: bad color sequence: (57, 88, 128)
求求了
本帖最后由 南归 于 2021-6-7 18:27 编辑 # 看了一下源码发现了这个,既然乘x的话,那就控制在0-1之内,乘完后r,g,b也在0-255之间,
修改为以下
a = random.random()
b = random.random()
c = random.random()
turtle.fillcolor(a, b, c)
# 但内层圆会被覆盖,需要继续修改代码
|
|