个人心得:python这么火是有他的原因的,突然发现他的语言很有趣,库函数也很多。
这次是第一步,简单了解了一下turtle函数
1 import turtle 2 import time 3 4 def drawSnake(rad, angle, len,neckrad ): 5 for i in range(len): 6 turtle.circle(rad,angle) 7 turtle.circle(-rad,angle) 8 turtle.circle(rad,angle/2) 9 turtle.fd(rad) 10 turtle.circle(neckrad+1, 180) 11 turtle.fd(rad/2*3) 12 def drakSnack_c(rad,len): 13 turtle.seth(0) 14 turtle.fd(rad) 15 turtle.seth(120) 16 turtle.fd(rad) 17 turtle.seth(240) 18 turtle.fd(rad) 19 turtle.fd(50) 20 turtle.circle(len*2) 21 22 23 def main(): 24 turtle.setup(0.85,0.6,0,0) 25 pythonsize = 1 26 speed = 5 27 turtle.speed(speed) 28 turtle.pensize(pythonsize) 29 #turtle.pencolor("red") 30 #turtle.seth(-40) 31 #drawSnake(40,80,5,pythonsize/2) 32 getflower() 33 34 def text(): 35 turtle.write("hello world!",font=("Arial",23,"bold")) 36 time.sleep(2) 37 38 def getflower(): 39 turtle.bgpic("timg.gif") 40 turtle.color("red","yellow") 41 turtle.begin_fill(); 42 for i in range(50): 43 turtle.fd(200) 44 turtle.left(170) 45 turtle.end_fill() 46 time.sleep(2) 47 48 49 main()