import turtle import time import datetime turtle.setup(1000,800) turtle.pensize(5) starttime = datetime.datetime.now() print(starttime) for i in range(9): if i < 2: turtle.pencolor('purple') turtle.fd(200) elif i < 3: turtle.pencolor('purple') turtle.seth(120) turtle.fd(200) elif i < 4: turtle.pencolor('purple') turtle.fd(200) elif i == 4: turtle.pencolor('purple') turtle.left(120) turtle.fd(200) time.sleep(5) elif i == 5: turtle.pencolor('red') turtle.left(120) turtle.fd(200) elif i == 6: turtle.pencolor('red') turtle.right(120) turtle.fd(200) elif i == 7: turtle.pencolor('red') turtle.right(120) turtle.fd(200) time.sleep(5) else: turtle.pencolor('purple') turtle.left(120) turtle.fd(200) m=time.gmtime() print(time.strftime("%Y-%m-%d %H:%M:%S",m)) endtime = datetime.datetime.now() print ((endtime - starttime).seconds) turtle.done()
python有关turtle的用法例子
最新推荐文章于 2024-11-08 13:43:44 发布