使用Python过中秋节来自程序员的浪漫《嫦娥奔月》_python画一个嫦娥!

用Python模拟嫦娥奔月:从神话到轨道计算 航天工程虽然高深,但核心原理正是牛顿力学与数值计算的结合。从神话“奔月”的想象出发,现代轨道设计依赖坐标、速度与时间戳的精密求解。本文从万有引力公式和限制性二体问题切入,解释如何用霍曼转移估算地月转移所需的速度增量,并通过四阶Runge-Kutta数值积分方法,在Python中一步步搭建可运行的奔月轨道模拟。这类仿真实践不仅能直观理解航天器变轨与捕获的物理逻辑,也是普通人接触轨道力学、航天编程最友好的入口。文章还探讨了坐标单位、积分步长选择等工程陷阱,并延伸到星载AI与数字孪生的未来趋势。无论你是Pytho 阅读详情

一、前言

    大家好,欢迎来到中秋创作,提前祝大家中秋节快乐。嫦娥相信大家不会陌生,她是中国古代神话中的人物。熟话说:“嫦娥飞天去,神州归来也”,今天使用海龟库给大家画一幅嫦娥奔月图。

嫦娥飞天去,神州归来也

在文章开始前打个小广告——分享一份Python学习大礼包(激活码+安装包、Python web开发,Python爬虫,Python数据分析,人工智能、自动化办公等学习教程)点击领取,100%免费!

二、效果展示

让大家看看嫦娥小姐姐。🤣🤣🤣

中秋·赏月吟
楠

花好月圆时,中秋佳节至,手中白瓷杯,月在杯中醉。

饮一掬月色,话一世浮沉,忽觉眼前人,更胜天上月。

三、代码解析

将代码模块化,使用函数来划分,一个一个的分解,到最后在调用组合,使复杂的问题简单化。

3.1初始化背景,设置窗口大小及背景颜色
def draw_bg():
    t.penup()
    t.goto(-700, -350)
    t.pendown()
    t.color((30, 30, 60), (30, 30, 60))
    t.begin_fill()
    t.goto(700, -350)
    t.goto(700, 350)
    t.goto(-700, 350)
    t.goto(-700, -350)
    t.end_fill()
    t.penup()

def init_draw():
    t.setup(1400, 700, startx=100, starty=100)
    t.colormode(255)
    # 这样设置背景导出的图片看不到背景
    # t.bgcolor(30, 30, 60)
    # 画背景
    draw_bg()

3.2 画星星,随机生成不同颜色的星星
def draw_star(s):
    t.begin_fill()
    for _ in range(6):
        t.forward(s)
        t.right(270)
        t.forward(s)
        t.right(150)
    t.end_fill()

def draw_stars(sn):
    for _ in range(sn):
        t.penup()
        t.goto(r.randint(-500, 600), r.randint(-100, 300))
        t.pendown()
        c = r.choice(('purple', 'green', 'yellow', 'white', 'blue'))
        t.color(c, c)
        t.seth(30)
        draw_star(r.randint(2, 5))

3.3 画假山
def draw_mount(d, a):
    t.penup()
    t.goto(-699-a*d, math.cos(a*(-699+699)/d)*d-100*a)
    t.pendown()
    t.begin_fill()
    for x in range(-700, 1000):
        t.goto(x-a*d, math.cos(a*(x+699)/d)*d-100*a)
    t.goto(700, -700)
    t.goto(-700, -700)
    t.goto(-699-a*d, math.cos(a*(-699+699)/d)*d-100*a)
    t.end_fill()

def draw_mounts():
    t.color('#90EE90', '#90EE90')
    draw_mount(80, 1)
    t.color('#87CEEB', '#87CEEB')
    draw_mount(70, 1.75)
    t.color('#7D9EC0', '#7D9EC0')
    draw_mount(60, 2.5)

3.4 画月亮,有不同形状的月亮选择,圆的月亮,弯的月亮。
def draw_moon():
    t.penup()
    # t.goto(-510, 300)
    t.goto(-550, 300)
    t.pendown()
    t.color('yellow', 'yellow')
    t.begin_fill()
    # 弯月
    # t.right(15)
    # t.circle(-60, 220)
    # t.right(140)
    # t.circle(60, 140)
    # 圆月
    t.right(15)
    t.circle(-100)
    t.end_fill()

3.5 画广寒宫
def draw_frool(y, j, w, h):
    # 房框
    t.penup()
    t.goto(y, j)
    t.pendown()
    t.goto(y-w, j)
    t.goto(y-w, j+h)
    t.goto(y, j+h)
    t.goto(y, j)
    # 左房檐
    t.penup()
    t.goto(y-w, j+h)
    t.seth(180)
    t.pendown()
    t.circle(-(int(w/3)), 60)
    # 右房檐
    t.penup()
    t.goto(y, j+h)
    t.seth(0)
    t.pendown()
    t.circle(int(w/3), 60)
    # 房门
    if y==-480:
        t.penup()
        t.goto(y-int(w*0.3), j)
        t.pendown()
        t.goto(y-int(w*0.3), j+int(h/2))
        t.goto(y-w+int(w*0.3), j+int(h/2))
        t.goto(y-w+int(w*0.3), j)
        t.penup()
        t.goto(y-int(w*0.5), j+int(h/2))
        t.pendown()
        t.goto(y-int(w*0.5), j)
        t.penup()
        t.goto(y-int(w*0.42), j+int(h/4))
        t.pendown()
        t.circle(0.5)
        t.penup()
        t.goto(y-int(w*0.58), j+int(h/4))
        t.pendown()
        t.circle(0.5)
    # 画窗户
    else:
        t.penup()
        t.goto(y-int(w*0.2), j+int(h*0.2))
        t.pendown()
        t.goto(y-w+int(w*0.2), j+int(h*0.2))
        t.goto(y-w+int(w*0.2), j+h-int(h*0.2))
        t.goto(y-int(w*0.2), j+h-int(h*0.2))
        t.goto(y-int(w*0.2), j+int(h*0.2))
        t.penup()
        t.goto(y-int(w*0.5), j+int(h*0.2))
        t.pendown()
        t.goto(y-int(w*0.5), j+h-int(h*0.2))
        t.penup()
        t.goto(y-int(w*0.2), j+int(h*0.5))
        t.pendown()
        t.goto(y-w+int(w*0.2), j+int(h*0.5))

def draw_palace():
    t.color('white')
    t.width(4)
    draw_frool(-480, 160, 100, 60)
    draw_frool(-500, 220, 60, 25)
    draw_frool(-510, 245, 40, 20)
    draw_frool(-518, 265, 24, 12)
    draw_frool(-524, 277, 12, 8)
    draw_frool(-528, 285, 4, 2)

3.6 画树
def draw_tree(s, f=5, h=90):
    if f == 0:
        return
    t.pendown()
    t.seth(h)
    t.fd(s+10 if f==5 else s)
    draw_tree(s>>1, f-1, h+45)
    t.penup()
    t.seth(h+45+180); t.fd(s>>1)
    draw_tree(s>>1, f-1, h-45)
    t.penup()
    t.seth(h-45+180); t.fd(s>>1)

3.7 画吴刚
def draw_WuGang():
    t.width(2)
    # 头
    ## 脸
    t.penup()
    t.goto(-472, 162)
    t.seth(70)
    t.pendown()
    t.color('black')
    t.circle(6, 140)
    t.color('#b3c518')
    t.circle(6, 220)
    ## 发髻
    t.penup()
    t.circle(6, 10)
    t.pendown()
    t.color('black')
    t.begin_fill()
    t.circle(-2)
    t.end_fill()
    ## 眼
    t.penup()
    t.goto(-478, 165)
    t.seth(90)
    t.pendown()
    t.fd(2)
    ## 嘴
    t.penup()
    t.goto(-481, 161)
    t.seth(-30)
    t.pendown()
    t.color('pink')
    t.circle(3, 50)
    # 身体
    ## 腰
    t.penup()
    t.color('#386650', '#386650')
    t.goto(-482, 143)
    t.pendown()
    t.seth(-110)
    t.fd(12)
    t.circle(1, 160)
    t.fd(12)
    t.right(120)
    t.fd(12)
    t.circle(1, 160)
    t.fd(14)
    ## 右肩
    t.penup()
    t.color('#5cd29b')
    t.seth(-1)
    t.goto(-475, 158)
    t.pendown()
    t.circle(-6, 90)
    ## 右手
    t.fd(3)
    t.color(skin)
    t.left(149)
    t.fd(1)
    t.circle(-2, 180)
    t.fd(2)
    t.circle(-4, 150)
    t.color('#4cd29b')
    t.fd(3)
    # 身体中插入一个斧子 #
    ###################
    ## 斧子把
    t.penup()
    t.goto(-486, 143)
    t.color('brown')
    t.pendown()
    t.goto(-456, 152)
    ## 斧子头
    t.penup()
    t.width(1)
    t.goto(-458, 148)
    t.color('black', 'black')
    t.pendown()
    t.begin_fill()
    t.seth(190)
    t.fd(1)
    t.right(90)
    t.fd(3)
    t.circle(8, 60)
    t.right(110)
    t.circle(-8, 80)
    t.right(110)
    t.circle(8, 60)
    t.fd(4)
    t.end_fill()
    ###################
    ## 左肩
    t.penup()
    t.width(2)
    t.color('#4cd29b')
    t.seth(180)
    t.goto(-482, 158)
    t.pendown()
    t.circle(5, 90)
    ## 左手
    t.fd(5)
    t.color(skin)
    t.circle(2, 60)
    t.fd(4)
    t.circle(2, 180)
    t.fd(3)
    t.color('#5cd29b')
    t.circle(-1, 60)
    t.fd(3)

3.8 画嫦娥姐姐
def draw_ChangE():
    lx, ly = -530, 170
    # 左手
    t.penup()
    t.color(skin)
    t.width(4)
    t.goto(lx, ly)
    t.seth(50)
    t.pendown()
    t.fd(10)
    t.circle(-3, 180)
    t.right(170)
    t.circle(-6, 180)
    t.circle(-50, 20)
    # 左袖
    t.penup()
    t.color('red')
    t.goto(lx, ly)
    t.seth(-140)
    t.pendown()
    t.fd(16)
    t.penup()
    t.goto(lx, ly)
    t.seth(-50)
    t.pendown()
    t.fd(30)
    t.right(90)
    t.fd(10)
    t.circle(-50, 40)
    # 衣服
    t.color('#f3dd64')
    t.penup()
    t.right(90)
    t.fd(10)
    t.right(180)
    t.pendown()
    t.circle(-100, 8)
    t.circle(-20, 80)
    t.circle(-100, 11)
    # 衣服2
    t.penup()
    t.circle(-100, -11)
    t.circle(-20, -80)
    t.fd(8)
    t.pendown()
    t.circle(-100, 6)
    t.circle(-15, 82)
    t.circle(-40, 35)
    # 衣服-裙
    t.color('red')
    t.penup()
    t.circle(-40, -35)
    t.circle(-15, -82)
    t.fd(10)
    t.right(10)
    t.pendown()
    t.circle(-100, 60)
    t.right(60)
    t.circle(-100, 60)
    t.right(60)
    t.circle(-200, 2)
    # 右袖
    t.penup()
    t.circle(-200, -2)
    t.right(-60)
    t.circle(-100, -60)
    t.right(-60)
    t.circle(-100, -60)
    t.right(-10)
    t.fd(-6)
    t.circle(-100, -6)
    t.fd(-8)
    t.circle(-20, 80)
    t.circle(-100, 12)
    t.right(110)
    t.fd(10)
    t.right(180)
    t.pendown()
    t.circle(-50, 50)
    t.right(70)
    t.circle(-50, 40)
    t.right(57)
    t.circle(-200, 10)
    # 右手
    t.penup()
    t.circle(-200, -10)
    t.right(-57)
    t.circle(-50, -4)
    t.color(skin)
    t.left(80)
    t.circle(10, 15)
    t.pendown()
    t.circle(10, 190)
    # 下方飘带
    t.penup()
    t.circle(10, -90)
    t.seth(-140)
    t.color('#f3dd64')
    t.circle(-10, 10)
    t.pendown()
    t.circle(-10, 100)
    t.circle(-40, 20)
    t.circle(40, 70)
    t.left(80)
    t.circle(60, 40)
    t.left(60)
    t.circle(-30, 50)
    t.circle(20, 80)
    t.fd(25)
    # 脸
    t.penup()
    t.goto(lx, ly)
    t.seth(-140)
    t.fd(16)
    t.seth(-100)
    t.color(skin)
    t.pendown()
    t.circle(-30, 100)
    t.color('black')
    t.begin_fill()
    t.circle(-30, 30)
    # 耳朵
    t.left(100)
    t.circle(-10, 180)
    t.circle(-2, 60)
    t.circle(-40, 20)
    # 头发
    t.left(150)
    t.circle(-10, 90)
    t.circle(80, 10)
    t.circle(30, 60)
    t.right(100)
    t.circle(-20, 70)
    t.circle(3, 160)
    t.circle(25, 90)
    t.left(20)
    t.fd(20)
    t.right(80)
    t.circle(20, 150)
    t.right(80)
    t.circle(8, 180)
    t.right(90)
    t.fd(10)
    t.right(110)
    t.circle(10, 100)
    t.right(110)
    t.fd(12)
    t.circle(8, 110)
    t.right(50)
    t.circle(12, 70)
    t.circle(2, 50)
    t.circle(180, 25)
    t.end_fill()
    # 发髻
    t.penup()
    t.circle(180, -25)
    t.circle(2, -50)
    t.circle(12, -70)
    t.right(-50)
    t.circle(8, -110)
    t.fd(-12)
    t.right(-110)
    t.circle(10, -100)
    t.right(-110)
    t.fd(-10)
    t.right(-90)
    t.circle(8, -180)
    t.fd(-25)
    t.left(20)
    t.color('yellow')
    t.width(1)
    t.pendown()
    t.begin_fill()
    t.fd(8)
    t.right(90)
    t.circle(-4, 180)
    t.end_fill()
    # 脸
    t.penup()
    t.width(1)
    t.goto(lx, ly)
    t.seth(-140)
    t.fd(16)
    t.seth(-100)
    t.color(skin)
    t.pendown()
    t.begin_fill()
    t.circle(-30, 130)
    t.left(100)
    t.circle(-10, 180)
    t.circle(-2, 60)
    t.circle(-40, 20)
    t.left(150)
    t.circle(-10, 90)
    t.circle(80, 10)
    t.circle(30, 60)
    t.right(100)
    t.circle(-20, 70)
    t.left(3)
    t.circle(-200, 9)
    t.end_fill()
    # 眼睛
    t.penup()
    t.width(6)
    t.goto(lx, ly)
    t.color('black')
    t.seth(170)
    t.fd(25)
    t.pendown()
    t.seth(120)
    t.fd(4)
    t.penup()
    t.left(90)
    t.fd(30)
    t.left(90)
    t.pendown()
    t.fd(4)
    # 嘴
    t.penup()
    t.circle(100, 10)
    t.width(4)
    t.left(40)
    t.color('red')
    t.pendown()
    t.circle(100, 3)
    t.circle(15, 90)
    t.circle(100, 3)

四、完整代码

import turtle as t
import time
import random as r 
import math
skin = '#ffffeb'

def draw_bg():
    t.penup()
    t.goto(-700, -350)
    t.pendown()
    t.color((30, 30, 60), (30, 30, 60))
    t.begin_fill()
    t.goto(700, -350)
    t.goto(700, 350)
    t.goto(-700, 350)
    t.goto(-700, -350)
    t.end_fill()
    t.penup()

def init_draw():
    t.setup(1400, 700, startx=100, starty=100)
    t.colormode(255)
    # 这样设置背景导出的图片看不到背景
    # t.bgcolor(30, 30, 60)
    # 画背景
    draw_bg()

def draw_moon():
    t.penup()
    # t.goto(-510, 300)
    t.goto(-550, 300)
    t.pendown()
    t.color('yellow', 'yellow')
    t.begin_fill()
    # 弯月
    # t.right(15)
    # t.circle(-60, 220)
    # t.right(140)
    # t.circle(60, 140)
    # 圆月
    t.right(15)
    t.circle(-100)
    t.end_fill()

def draw_star(s):
    t.begin_fill()
    for _ in range(6):
        t.forward(s)
        t.right(270)
        t.forward(s)
        t.right(150)
    t.end_fill()

def draw_stars(sn):
    for _ in range(sn):
        t.penup()
        t.goto(r.randint(-500, 600), r.randint(-100, 300))
        t.pendown()
        c = r.choice(('purple', 'green', 'yellow', 'white', 'blue'))
        t.color(c, c)
        t.seth(30)
        draw_star(r.randint(2, 5))

def draw_mount(d, a):
    t.penup()
    t.goto(-699-a*d, math.cos(a*(-699+699)/d)*d-100*a)
    t.pendown()
    t.begin_fill()
    for x in range(-700, 1000):
        t.goto(x-a*d, math.cos(a*(x+699)/d)*d-100*a)
    t.goto(700, -700)
    t.goto(-700, -700)
    t.goto(-699-a*d, math.cos(a*(-699+699)/d)*d-100*a)
    t.end_fill()

def draw_mounts():
    t.color('#90EE90', '#90EE90')
    draw_mount(80, 1)
    t.color('#87CEEB', '#87CEEB')
    draw_mount(70, 1.75)
    t.color('#7D9EC0', '#7D9EC0')
    draw_mount(60, 2.5)

def draw_tree(s, f=5, h=90):
    if f == 0:
        return
    t.pendown()
    t.seth(h)
    t.fd(s+10 if f==5 else s)
    draw_tree(s>>1, f-1, h+45)
    t.penup()
    t.seth(h+45+180); t.fd(s>>1)
    draw_tree(s>>1, f-1, h-45)
    t.penup()
    t.seth(h-45+180); t.fd(s>>1)

def draw_WuGang():
    t.width(2)
    # 头
    ## 脸
    t.penup()
    t.goto(-472, 162)
    t.seth(70)
    t.pendown()
    t.color('black')
    t.circle(6, 140)
    t.color('#b3c518')
    t.circle(6, 220)
    ## 发髻
    t.penup()
    t.circle(6, 10)
    t.pendown()
    t.color('black')
    t.begin_fill()
    t.circle(-2)
    t.end_fill()
    ## 眼
    t.penup()
    t.goto(-478, 165)
    t.seth(90)
    t.pendown()
    t.fd(2)
    ## 嘴
    t.penup()
    t.goto(-481, 161)
    t.seth(-30)
    t.pendown()
    t.color('pink')
    t.circle(3, 50)
    # 身体
    ## 腰
    t.penup()
    t.color('#386650', '#386650')
    t.goto(-482, 143)
    t.pendown()
    t.seth(-110)
    t.fd(12)
    t.circle(1, 160)
    t.fd(12)
    t.right(120)
    t.fd(12)
    t.circle(1, 160)
    t.fd(14)
    ## 右肩
    t.penup()
    t.color('#5cd29b')
    t.seth(-1)
    t.goto(-475, 158)
    t.pendown()
    t.circle(-6, 90)
    ## 右手
    t.fd(3)
    t.color(skin)
    t.left(149)
    t.fd(1)
    t.circle(-2, 180)
    t.fd(2)
    t.circle(-4, 150)
    t.color('#4cd29b')
    t.fd(3)
    # 身体中插入一个斧子 #
    ###################
    ## 斧子把
    t.penup()
    t.goto(-486, 143)
    t.color('brown')
    t.pendown()
    t.goto(-456, 152)
    ## 斧子头
    t.penup()
    t.width(1)
    t.goto(-458, 148)
    t.color('black', 'black')
    t.pendown()
    t.begin_fill()
    t.seth(190)
    t.fd(1)
    t.right(90)
    t.fd(3)
    t.circle(8, 60)
    t.right(110)
    t.circle(-8, 80)
    t.right(110)
    t.circle(8, 60)
    t.fd(4)
    t.end_fill()
    ###################
    ## 左肩
    t.penup()
    t.width(2)
    t.color('#4cd29b')
    t.seth(180)
    t.goto(-482, 158)
    t.pendown()
    t.circle(5, 90)
    ## 左手
    t.fd(5)
    t.color(skin)
    t.circle(2, 60)
    t.fd(4)
    t.circle(2, 180)
    t.fd(3)
    t.color('#5cd29b')
    t.circle(-1, 60)
    t.fd(3)

def draw_frool(y, j, w, h):
    # 房框
    t.penup()
    t.goto(y, j)
    t.pendown()
    t.goto(y-w, j)
    t.goto(y-w, j+h)
    t.goto(y, j+h)
    t.goto(y, j)
    # 左房檐
    t.penup()
    t.goto(y-w, j+h)
    t.seth(180)
    t.pendown()
    t.circle(-(int(w/3)), 60)
    # 右房檐
    t.penup()
    t.goto(y, j+h)
    t.seth(0)
    t.pendown()
    t.circle(int(w/3), 60)
    # 房门
    if y==-480:
        t.penup()
        t.goto(y-int(w*0.3), j)
        t.pendown()
        t.goto(y-int(w*0.3), j+int(h/2))
        t.goto(y-w+int(w*0.3), j+int(h/2))
        t.goto(y-w+int(w*0.3), j)
        t.penup()
        t.goto(y-int(w*0.5), j+int(h/2))
        t.pendown()
        t.goto(y-int(w*0.5), j)
        t.penup()
        t.goto(y-int(w*0.42), j+int(h/4))
        t.pendown()
        t.circle(0.5)
        t.penup()
        t.goto(y-int(w*0.58), j+int(h/4))
        t.pendown()
        t.circle(0.5)
    # 画窗户
    else:
        t.penup()
        t.goto(y-int(w*0.2), j+int(h*0.2))
        t.pendown()
        t.goto(y-w+int(w*0.2), j+int(h*0.2))
        t.goto(y-w+int(w*0.2), j+h-int(h*0.2))
        t.goto(y-int(w*0.2), j+h-int(h*0.2))
        t.goto(y-int(w*0.2), j+int(h*0.2))
        t.penup()
        t.goto(y-int(w*0.5), j+int(h*0.2))
        t.pendown()
        t.goto(y-int(w*0.5), j+h-int(h*0.2))
        t.penup()
        t.goto(y-int(w*0.2), j+int(h*0.5))
        t.pendown()
        t.goto(y-w+int(w*0.2), j+int(h*0.5))

def draw_palace():
    t.color('white')
    t.width(4)
    draw_frool(-480, 160, 100, 60)
    draw_frool(-500, 220, 60, 25)
    draw_frool(-510, 245, 40, 20)
    draw_frool(-518, 265, 24, 12)
    draw_frool(-524, 277, 12, 8)
    draw_frool(-528, 285, 4, 2)

def draw_ChangE():
    lx, ly = -530, 170
    # 左手
    t.penup()
    t.color(skin)
    t.width(4)
    t.goto(lx, ly)
    t.seth(50)
    t.pendown()
    t.fd(10)
    t.circle(-3, 180)
    t.right(170)
    t.circle(-6, 180)
    t.circle(-50, 20)
    # 左袖
    t.penup()
    t.color('red')
    t.goto(lx, ly)
    t.seth(-140)
    t.pendown()
    t.fd(16)
    t.penup()
    t.goto(lx, ly)
    t.seth(-50)
    t.pendown()
    t.fd(30)
    t.right(90)
    t.fd(10)
    t.circle(-50, 40)
    # 衣服
    t.color('#f3dd64')
    t.penup()
    t.right(90)
    t.fd(10)
    t.right(180)
    t.pendown()
    t.circle(-100, 8)
    t.circle(-20, 80)
    t.circle(-100, 11)
    # 衣服2
    t.penup()
    t.circle(-100, -11)
    t.circle(-20, -80)
    t.fd(8)
    t.pendown()
    t.circle(-100, 6)
    t.circle(-15, 82)
    t.circle(-40, 35)
    # 衣服-裙
    t.color('red')
    t.penup()
    t.circle(-40, -35)
    t.circle(-15, -82)
    t.fd(10)
    t.right(10)
    t.pendown()
    t.circle(-100, 60)
    t.right(60)
    t.circle(-100, 60)
    t.right(60)
    t.circle(-200, 2)
    # 右袖
    t.penup()
    t.circle(-200, -2)
    t.right(-60)
    t.circle(-100, -60)
    t.right(-60)
    t.circle(-100, -60)
    t.right(-10)
    t.fd(-6)
    t.circle(-100, -6)
    t.fd(-8)
    t.circle(-20, 80)
    t.circle(-100, 12)
    t.right(110)
    t.fd(10)
    t.right(180)
    t.pendown()
    t.circle(-50, 50)
    t.right(70)
    t.circle(-50, 40)
    t.right(57)
    t.circle(-200, 10)
    # 右手
    t.penup()
    t.circle(-200, -10)
    t.right(-57)
    t.circle(-50, -4)
    t.color(skin)
    t.left(80)
    t.circle(10, 15)
    t.pendown()
    t.circle(10, 190)
    # 下方飘带
    t.penup()
    t.circle(10, -90)
    t.seth(-140)
    t.color('#f3dd64')
    t.circle(-10, 10)
    t.pendown()
    t.circle(-10, 100)
    t.circle(-40, 20)
    t.circle(40, 70)
    t.left(80)
    t.circle(60, 40)
    t.left(60)
    t.circle(-30, 50)
    t.circle(20, 80)
    t.fd(25)
    # 脸
    t.penup()
    t.goto(lx, ly)
    t.seth(-140)
    t.fd(16)
    t.seth(-100)
    t.color(skin)
    t.pendown()
    t.circle(-30, 100)
    t.color('black')
    t.begin_fill()
    t.circle(-30, 30)
    # 耳朵
    t.left(100)
    t.circle(-10, 180)
    t.circle(-2, 60)
    t.circle(-40, 20)
    # 头发
    t.left(150)
    t.circle(-10, 90)
    t.circle(80, 10)
    t.circle(30, 60)
    t.right(100)
    t.circle(-20, 70)
    t.circle(3, 160)
    t.circle(25, 90)
    t.left(20)
    t.fd(20)
    t.right(80)
    t.circle(20, 150)
    t.right(80)
    t.circle(8, 180)
    t.right(90)
    t.fd(10)
    t.right(110)
    t.circle(10, 100)
    t.right(110)
    t.fd(12)
    t.circle(8, 110)
    t.right(50)
    t.circle(12, 70)
    t.circle(2, 50)
    t.circle(180, 25)
    t.end_fill()
    # 发髻
    t.penup()
    t.circle(180, -25)
    t.circle(2, -50)
    t.circle(12, -70)
    t.right(-50)
    t.circle(8, -110)
    t.fd(-12)
    t.right(-110)
    t.circle(10, -100)
    t.right(-110)
    t.fd(-10)
    t.right(-90)
    t.circle(8, -180)
    t.fd(-25)
    t.left(20)
    t.color('yellow')
    t.width(1)
    t.pendown()
    t.begin_fill()
    t.fd(8)
    t.right(90)
    t.circle(-4, 180)
    t.end_fill()
    # 脸
    t.penup()
    t.width(1)
    t.goto(lx, ly)
    t.seth(-140)
    t.fd(16)
    t.seth(-100)
    t.color(skin)
    t.pendown()
    t.begin_fill()
    t.circle(-30, 130)
    t.left(100)
    t.circle(-10, 180)
    t.circle(-2, 60)
    t.circle(-40, 20)
    t.left(150)
    t.circle(-10, 90)
    t.circle(80, 10)
    t.circle(30, 60)
    t.right(100)
    t.circle(-20, 70)
    t.left(3)
    t.circle(-200, 9)
    t.end_fill()
    # 眼睛
    t.penup()
    t.width(6)
    t.goto(lx, ly)
    t.color('black')
    t.seth(170)
    t.fd(25)
    t.pendown()
    t.seth(120)
    t.fd(4)
    t.penup()
    t.left(90)
    t.fd(30)
    t.left(90)
    t.pendown()
    t.fd(4)
    # 嘴
    t.penup()
    t.circle(100, 10)
    t.width(4)
    t.left(40)
    t.color('red')
    t.pendown()
    t.circle(100, 3)
    t.circle(15, 90)
    t.circle(100, 3)

def add_moon_palace():
    # 画月宫
    draw_palace()
    # 画树
    t.penup()
    t.color('brown')
    t.goto(-500, 110)
    t.width(3)
    draw_tree(80)
    # 画吴刚
    draw_WuGang()
    # 画嫦娥
    draw_ChangE()

def save_draw():
    ts = t.getscreen()
    ts.getcanvas().postscript(file='o.eps')

if __name__ == '__main__':
    t.speed(100)
    init_draw()
    t.speed(10)
    t.speed(40)
    draw_stars(30)
    t.speed(100)
    draw_mounts()
    t.speed(10)
    draw_moon()
    t.speed(100)
    add_moon_palace()
    t.penup()
    t.speed(100)
    t.goto(0, -700)
    save_draw()
    time.sleep(9)
    t.mainloop()

关于Python技术储备

学好 Python 不论是就业还是做副业赚钱都不错,但要学会 Python 还是要有一个学习规划。最后给大家分享一份全套的 Python 学习资料,给那些想学习 Python 的小伙伴们一点帮助!

包括:Python激活码+安装包、Python web开发,Python爬虫,Python数据分析,人工智能、自动化办公等学习教程。带你从零基础系统性的学好Python!

点击领取 100%免费!

👉Python所有方向的学习路线👈

Python所有方向路线就是把Python常用的技术点做整理,形成各个领域的知识点汇总,它的用处就在于,你可以按照上面的知识点去找对应的学习资源,保证自己学得较为全面。(全套教程文末领取)

在这里插入图片描述

👉Python学习视频600合集👈

观看零基础学习视频,看视频学习是最快捷也是最有效果的方式,跟着视频中老师的思路,从基础到深入,还是很容易入门的。

在这里插入图片描述

温馨提示:篇幅有限,已打包文件夹,获取方式在:文末
👉Python70个实战练手案例&源码👈

光学理论是没用的,要学会跟着一起敲,要动手实操,才能将自己的所学运用到实际当中去,这时候可以搞点实战案例来学习。

在这里插入图片描述

👉Python大厂面试资料👈

我们学习Python必然是为了找到高薪的工作,下面这些面试题是来自阿里、腾讯、字节等一线互联网大厂最新的面试资料,并且有阿里大佬给出了权威的解答,刷完这一套面试资料相信大家都能找到满意的工作。

在这里插入图片描述

在这里插入图片描述

👉Python副业兼职路线&方法👈

学好 Python 不论是就业还是做副业赚钱都不错,但要学会兼职接单还是要有一个学习规划。

在这里插入图片描述

👉 这份完整版的Python全套学习资料已经上传,朋友们如果需要可以扫描下方优快云官方认证二维码或者点击链接免费领取【保证100%免费】

![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/711c5966aa7348dc9340894eea54e99f.png#pic_center在这里插入图片描述

【python】中秋主题案例程序 这个程序通过简单的文字描述和用户输入,模拟了一个寻找月饼的小故事。一个简单的Python程序示例,它使用了Python的基本功能来创建一个中秋节的问候程序。这个程序会模拟一个中秋节猜灯谜的活动,用户可以输入答案,程序会判断答案是否正确,并给出相应的提示。该程序能够展示中秋节的传统故事、习俗,并允许用户输入祝福语,最后以特殊的中秋节风格打印出来。程序将显示中秋节的介绍和习俗,然后提示用户输入祝福语,最后将装饰后的祝福语打印出来。这个程序将会是一个简单的互动式故事,关于一个寻找月饼的旅程。 阅读详情

相关推荐

NIST随机性测试实战:从理论公式到结果解读

本文详细解析了NIST随机性测试的实战应用,从基础测试到高级测试,涵盖频数测试、块频数测试、游程测试等核心方法。通过实际案例和参数设置经验,帮助读者理解如何解读测试结果并排查常见问题,提升随机数生成质量。文章还分享了自动化测试流程和硬件RNG特殊处理技巧,适合密码学和区块链开发者参考。

weixin_29323365的博客 317

【正则表达式】——10个非常常见的正则表达式案例,轻松搞定正则表达式

正则表达式是前端人必备必会的基础,快来和我一起学习这超级常用的10个案例,让你轻松且彻底明白学会正则表达式!

qq_50497708的博客 1万+

CCF201803-2 碰撞的小球 python

一些话:已经不知道是第几次做这道题了(大概第三次吧),真的常做常新,每次都有新的细节想法。虽然方法简单粗暴,但好在方便理解,对于我这种菜鸟选手而言。 但在做的过程中,最开始还忽略了输入的小球初始位置有可能是无序的,输出的时候要保持相对位置。CCF真的考验细节,希望上考场时能够认真仔细一点。就酱… #碰撞的小球 #当小球坐标为0或L时,会朝相反方向移动 #当两个小球坐标相等时,会分别转向相反的方向 #计算t秒之后小球的位置 n,L,t = map(int,input().split()) location .

tanya_dre的博客 351

10个python中使用正则表达式的场景!

这些正则表达式场景在处理文本时非常常见.掌握它们可以极大提高处理字符串操作的效率,同时也能使代码更加简洁明了.在Python中,正则表达式是不可或缺的工具,熟练运用它们能帮助你解决许多实际问题.

Python_trys的博客 1346

黑客渗透测试后门隐藏技术揭秘

本文介绍了在授权渗透测试中隐藏后门文件(muma.exe)的多种技术手段。主要包括:通过WinRAR自解压脚本将后门与正常程序捆绑实现双开;利用系统自动运行目录和注册表实现开机自启;修改文件图标伪装成常用软件;将文件存放在冷门系统目录;设置系统+隐藏双重属性增强隐蔽性。此外还涉及对抗安全软件的加壳(UPX)、免杀(msfvenom编码)技术,以及进程注入、日志清除等运行隐藏方法。所有技术仅限合法授权测试使用,未经授权使用将面临法律责任。

m0_60781580的博客 1040

YOLOv8自定义训练:车牌识别全流程(从标注到推理,附可视化代码)

车牌检测全流程实践指南 摘要:本文详细介绍了基于YOLOv8的车牌检测完整实现方案。针对车牌检测中的三大难点(小目标、多角度、光照变化),提供了从数据准备到模型部署的全流程解决方案。重点包括:1)数据采集与标注规范;2)针对小目标的YOLOv8模型优化配置;3)K-means锚框聚类方法;4)训练参数调优策略。通过实际验证,该方法可获得95%以上的检测准确率,并附有完整的代码实现和可视化工具,便于开发者快速复现应用。 (字数:149字)

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 851

详解Python正则表达式(含丰富案例)

正则表达式在网络爬虫、数据分析中有着广泛使用,掌握正则表达式能够达到事半功倍的效果。本文详细介绍正则表达式中各种规则及其符号含义,并结合Python中的Re库进行演示,由浅入深,即学即练即用,内容丰富,非常适合初学者。

手把手教你学编程 1万+

【docker】第10篇 Failed with result ‘exit-code和Start request repeated too quickly和Failed to start Docker

【docker】解决 Failed with result 'exit-code'和Start request repeated too quickly和Failed to start Docker。

Fanjufei的博客 6820

正则表达式常用例子汇总

正则匹配全部汇总: 目录 正则匹配全部汇总: 一、校验数字的表达式 二、校验字符的表达式 三、特殊需求表达式 1、匹配中文:[\u4e00-\u9fa5] 2、英文字母:[a-zA-Z] 3、数字:[0-9] 4、匹配中文,英文字母和数字及下划线:^[\u4e00-\u9fa5_a-zA-Z0-9]+$ 同时判断输入长度: [\u4e00-\u9fa5_a-zA-Z0-9_]{4,10} 5、 (?!_)  不能以_开头 (?!.*?_$)  不能以_结尾 [a-zA-Z0-9..

liu1525084979的博客 2万+

Agent Harness Engineering: AI Agent 执行管控与安全沙箱 原理与最佳实践

我们正站在计算范式转移的历史节点上。2024-2026 年间,AI 系统从被动的内容生成器(Generative AI)演变为主动的行动执行者(Agentic AI)。这一转变的根本特征是:根据 2026 年初的行业数据:然而,能力的提升伴随着风险的指数级增长。2024-2026 年间发生的多起标志性安全事件揭示了 Agent 系统的脆弱性:案例 1:Slack AI 数据外泄事件(2024 年 8 月)案例 2:制造业供应链攻击(2026 年 Q3)案例 3:Arup 深度诈骗案(2026 年 9 月)这

AI天才研究院 1670

RK3588开发笔记-USB3.0接口调试

RK3588平台是一款强大的处理器,但要充分发挥其性能,需要正确调试其各种接口,包括USB 3.0接口。USB 3.0接口提供了更快的数据传输速度,但也可能面临一些问题。本篇博客将介绍如何在RK3588平台上调试USB 3.0接口,以确保其稳定性和性能。RK3588芯片具有强大的USB资源,包括多个USB接口和高速数据传输能力。RK3588通常具有多个USB接口,包括USB 2.0和USB 3.0。USB 2.0用于低速和全速设备连接,而USB 3.0则用于高速设备连接。

flypig has a dream! 2561

分享 5 个关于正则表达式的实际应用场景

在计算机编程的广泛领域中,某些技术具有改变我们如何处理和提取文本内容中信息的能力。在这些强大工具中,正则表达式成为每个开发者工具库中基本且不可或缺的组成部分。正则表达式,通常被称为 RegEx ,为程序员提供了高效且多功能的解决方案,适用于各种编程应用。本教程将探讨它们的重要性,并展示五个实际应用案例,包括数据验证、数据提取、日志解析、搜索和替换以及数据清理。正则表达式,通常简称为 RegEx ,...

前端达人 2772

【EMC专题】为什么芯片规格书ESD性能中看不到MM(机器放电模型)

器件级ESD包括三种类型,HBM人体放电模型、MM机械放电模型和CDM元件充电模型。但在芯片规格书中为什么只见到HBM模型与CDM模型,却没有看到MM模型的数据?

一点硬件 451

【中秋征文】使用Python中秋节程序员的浪漫《嫦娥奔月》

大家好,我是猿童学🐵,欢迎来到中秋创作第三期,祝大家中秋节快乐。嫦娥相信大家不会陌生,她是中国古代神话中的人物。熟话说:“嫦娥飞天去,神州归来也”,今天使用海龟库给大家画一幅嫦娥奔月图。

君莫笑的博客 2万+

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

Python绘制小月亮

今天是中秋节,学习如何用Python画出一个月亮。

简简单单 5847

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

中秋与代码共舞:用Python、JS、Java打造你的专属中秋技术盛宴

在开始代码实践前,我们先聊聊中秋节的 “灵魂”—— 那些刻在中国人基因里的文化符号。理解这些背景,能让我们的代码作品更有温度。Python:用matplotlib绘制可定制月饼(支持口味切换、批量生成),用turtle实现玉兔跳动动画(搭配夜空圆月背景),适合入门级可视化学习;JavaScript:用Canvas开发互动灯笼(鼠标控制摆动 + 光晕变化),用 DOM 实现猜灯谜游戏(支持自动选题、答案判断),聚焦前端用户体验;Java。

Pocker_Spades_A的博客 1057

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

【榜单公布】中秋征文结果揭晓,谁更“技”高一筹?

一年一度的中秋团圆日已落下帷幕,博主们的比拼结果也已新鲜出炉,快来看看此次征文中,哪些精彩文章上榜了呢?一起来看!

优快云 官方博客 5643

双节同辉:传统与现代的时空对话;代码寄明月:用算法编织中秋浪漫

当中秋的皎洁月光与国庆的鲜艳红旗在数字世界中相遇,我们见证了传统与现代的完美融合。通过代码、算法和数据可视化,我们重新诠释了传统节日的文化内涵,让古老的文化在数字时代焕发新生。"月满华诞 · 码向未来"不仅是一个征文主题,更是我们在数字时代传承文化、创新表达的行动宣言。当中秋的明月与国庆的红旗在代码中相遇,当传统节日的温情与现代科技的脉搏共振,我们看到了文化传承的无限可能。让我们以代码为笔,以算法为墨,在数字世界的画卷上描绘家国情怀;让我们用二进制的语言,诉说对明月与华诞的祝福;

zzywxc787的博客 1135

裁纸奔月python_Python程序设计_知到智慧树_课后作业参考答案

更多相关问题:研究生阶段需要精读的文章是随着你研究的深入而越来越多专利之星检索系统检索专利时必须进行注册才能顺利检索专利。( ? ? )就是在需要战斗部爆炸的时候引爆战斗部用的。中国大学MOOC: 1987年召开的党的十三大,第一次比较系统地论述了我国社会主义( )关于乳腺X线摄影叙述错误的是6. In which of the following situations may the肌糖原分解...

weixin_39682940的博客 729

分享74个节日PPT,总有一款适合您

分享74个节日PPT,总有一款适合您

weixin_47730343的博客 964

分享68个节日PPT,总有一款适合您

分享68个节日PPT,总有一款适合您

weixin_47730343的博客 827
上一篇: python数据分析案例——泰坦尼克号幸存者预测!
下一篇: 100个python的基本语法知识【上】
Python_trys
博客等级 码龄2年 4379粉丝 377原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值