# -*- coding: utf-8 -*- import random as rd import turtle win = turtle.Screen() tt = turtle.Turtle() win.bgcolor('lightgreen') ###### tt.shape('turtle') def ranMoves(x,y,**kwargs): isStamp = False for k in kwargs.keys(): if k == 'pencolor': tt.pencolor(kwargs[k]) if k == 'stamp': if kwargs[k]==True: isStamp = True if k == 'bgcolor': win.bgcolor(kwargs[k]) if k == 'pensize': tt.pensize(kwargs[k]) tt.goto(x, y) if isStamp==True: tt.stamp() isStamp = False #----------使用上述方法----------# ranMoves(100,100, pencolor = 'blue', pensize = 3, stamp = True) ranMoves(50,20, pencolor = 'red',bgcolor = (0.3, 0.5, 0.7)) ranMoves(-30, 35, pensize = 5, pencolor = "#ff2300", stamp = True) ###### win.exitonclick()