#画同心圆
import turtle
import random
#生成随机颜色(16进制)
def randomcolor():
colorArr = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F']
color = ""
for i in range(6):
color += colorArr[random.randint(0,15)]
return "#"+color
t = turtle.Pen()
t.width(4)
t.speed(8)
for i in range(5):
t.penup()
t.goto(0,-50*i)
t.pendown()
r = random.randrange(0,257,10)
g = random.randrange(0,257,10)
b = random.randrange(0,257,10)
turtle.colormode(255) # 需要将turtle.colormode设置为255以提供Hex代码(16进制)或R G B中的颜色字符串.
# t.color(r,g,b) # RGB颜色格式
t.color( randomcolor()) # HEX格式
t.circle(100+i * 50)
turtle.done() # 程序执行完窗口仍然在