分享给大家几段有趣的代码,学会python画画可以不用自己动手啦(用Python画画)

网友投稿 4316 2022-09-19

分享给大家几段有趣的代码,学会python画画可以不用自己动手啦(用Python画画)

分享给大家几段有趣的代码,学会python画画可以不用自己动手啦(用Python画画)

前言

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梦头像

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:cmd基础 tasklist 查看系统进程信息
下一篇:cmd基础 systeminfo 查看系统配置信息
相关文章

 发表评论

暂时没有评论,来抢沙发吧~