↓ 源码如下 ↓
from turtle import *
from random import random, randint
screen = Screen()
width, height = 800, 600
screen.setup(width, height)
screen.bgcolor("black")
screen.mode("logo")
screen.delay(0) # 这里要设为0,否则很卡
t = Turtle(visible=False, shape='circle')
t.pencolor("white")
t.fillcolor("white")
t.penup()
t.setheading(-90)
t.goto(width / 2, randint(-height / 2, height / 2))
stars = []
#200颗星星
for i in range(200):
star = t.clone()
s = random() / 3
star.shapesize(s, s)
star.speed(int(s * 10))
star.setx(width / 2 + randint(1, width))
star.sety(randint(-height / 2, height / 2))
star.showturtle()
stars.append(star)
while True:
for star in stars:
star.setx(star.xcor() - 3 * star.speed())
if star.xcor() < -width / 2:
star.hideturtle()
star.setx(width / 2 + randint(1, width))
star.sety(randint(-height / 2, height / 2))
star.showturtle()
以上Python画图源码感兴趣的小伙伴,需要的可以看下方
一、Python所有方向的学习路线
Python所有方向的技术点做的整理,形成各个领域的知识点汇总,它的用处就在于,你可以按照下面的知识点去找对应的学习资源,保证自己学得较为全面。
二、Python必备开发工具
工具都帮大家整理好了,安装就可直接上手!
三、最新Python学习笔记
当我学到一定基础,有自己的理解能力的时候,会去阅读一些前辈整理的书籍或者手写的笔记资料,这些笔记详细记载了他们对一些技术点的理解,这些理解是比较独到,可以学到不一样的思路。
四、Python视频合集
观看全面零基础学习视频,看视频学习是最快捷也是最有效果的方式,跟着视频中老师的思路,从基础到深入,还是很容易入门的。
五、实战案例
纸上得来终觉浅,要学会跟着视频一起敲,要动手实操,才能将自己的所学运用到实际当中去,这时候可以搞点实战案例来学习。
六、面试宝典