原标题:使用Python的turtle画炫酷图形
例子一:
import turtle
t = turtle.Pen()
turtle.bgcolor("black")
sides=6
colors=["red","yellow","green","blue","orange","purple"]
for x in xrang(360):
t.pencolor(colors[x%sides])
t.forward(x*3/sides+x)
t.left(360/sides+1)
t.width(x*sides/200)
print("####结束####")
效果图如下:
例子二:
可以做成交互的,利用eval函数获得用户想绘制的边数
代码:
import turtle
t = turtle.Pen()
turtle.bgcolor("black")
sides=evali(input("输入要绘制的边的数目,请输入2-6的数字!"))
colors=["red","yellow","green","blue","orange","pu