前言

Python 是一门简单易学且功能强大的编程语言,无需繁琐的配置,掌握基本语法,了解基本库函数,就可以通过调用海量的现有工具包编写自己的程序,轻松实现批量自动化操作,可以极大提高办公和学习效率。Python爬虫可以批量获取网页上的数据。

Python几段代码也能让我们做出几个有趣的动画

1、旋转动画

#SquareSpiral1.py

import turtle

t = turtle.Pen()

turtle.bgcolor("black")

sides=6

colors=["red","yellow","green","blue","orange","purple"]for x in range(360):

t.pencolor(colors[x%sides])

t.forward(x*3/sides+x)

t.left(360/sides+1)

t.width(x*sides/200)

print("####结束####")

2、画纸飞机

import turtle

#太阳

turtle.color('red')

turtle.penup()

turtle.goto(250,200)

turtle.pendown()

turtle.begin_fill()

turtle.circle(50)

turtle.end_fill()

turtle.color('black','blue')

turtle.begin_fill()

#飞机

turtle.penup()

turtle.home()

turtle.pendown()

turtle.pensize(5)

turtle.goto(-300,150)

turtle.goto(100,50)

turtle.goto(0,0)

turtle.end_fill()

turtle.goto(-30,-125)

turtle.goto(-50,-50)

turtle.begin_fill()

turtle.goto(-300,150)

turtle.goto(-125,-125)

turtle.goto(-50,-50)

turtle.goto(-30,-125)

turtle.goto(-85,-85)

turtle.end_fill()

#线条

turtle.pensize(3)

turtle.penup()

turtle.goto(75,25)

turtle.pendown()

turtle.goto(200,0)

turtle.penup()

turtle.goto(50,-5)

turtle.pendown()

turtle.goto(250,-30)

turtle.penup()

turtle.goto(10,-80)

turtle.pendown()

turtle.goto(100,-150)

turtle.penup()

turtle.goto(-80,-125)

turtle.pendown()

turtle.goto(120,-200)

turtle.ht()

3、画小猪佩奇

4.画哆啦A梦头像

怎么样?回复小编私信“代码”获取吧~

欢迎点击右上角关注小编,除了分享技术文章之外还有很多福利,私信学习资料可以领取包括不限于Python实战演练、PDF电子文档、面试集锦、学习资料等。

更多推荐

python编程代码画画_分享给大家几段有趣的代码,学会python画画可以不用自己动手啦...