from turtle import * from random import randint,choice width,height = 600,600 color_list = ['red','orange','yellow','green','cyan','blue','purple'] screen = Screen() screen.setup(width,height) screen.bgcolor('white') screen.delay(0) screen.title('打点') t = Turtle() t.hideturtle() t.penup() while True: x = randint(-width/2,width/2) y = randint(-height/2,height/2) if y !=0 : if -50 < x%y < 50: ys = choice(color_list) t.pencolor(ys) t.goto(x,y) t.dot(10)
李兴球
李兴球的博客是Python创意编程原创博客