使用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全套学习资料已经上传,朋友们如果需要可以扫描下方CSDN官方认证二维码或者点击链接免费领取【保证100%免费】

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

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

相关推荐

Palantir 产品架构深度解析:从本体到AI的决策智能平台

本文深度解析了Palantir决策智能平台的核心产品架构。其核心在于构建企业级的“本体”(Ontology),即业务世界的“数字孪生”,通过数据、逻辑、操作三层抽象统一语义。平台以此为基础,通过Foundry构建数字孪生,并通过AIP(人工智能平台)实现本体增强生成(OAG),将AI深度融入业务,形成从数据感知、智能分析到行动执行的完整决策闭环。

ooo22的博客 740

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

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

qq_50497708的博客 1万+

Cadence Allegro通过手工绘制板框的方法

Cadence Allegro通过手工绘制板框的方法 Cadence Allegro绘制板框有三个方法: 1、通过手工绘制板框; 2、通过向导绘制板框; 3、通过导入DXF文件导绘制板框; 本章将教会大家如何通过手工的方法绘制100mm的矩形板框。 方法步骤如下: 一、通过放置绘图工具2D线绘制; 1、运行Cadence Allegro软件,打开File菜单栏,选择New。 2、这时软件会弹出Ne...

LGCPCB的博客 2万+

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

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

Python_trys的博客 1350

SAP BSP网页开发入门:从SE80创建到MVC实战(附成品展示)

本文详细介绍了SAP BSP网页开发的入门与实战,从SE80环境搭建到MVC架构实现的全流程。通过具体案例和代码示例,帮助开发者掌握业务服务器页面(BSP)技术,提升SAP Web化转型中的开发效率,适用于需要扩展SAP功能的企业场景。

x1y2z的博客 1万+

IBM x3650M4服务器更换主板后,导入原有硬盘阵列信息

x3650m4服务器主板坏了,更换好的主板,需要导入原来硬盘的里面的阵列信息 1、开机有提示信息,按C导入配置 2、按Y继续 3、点击start进入阵列卡配置 4、选择configurations 1,点击preview 5、预览硬盘的阵列信息,点击import导入 6、导入成功,可以查看到阵列信息 7、重启服务器,进入操作系统 如果重启找不到操作系统,重启按f12,手动选择从onboard sas controller启动,进入系统一次后面重启就会自动找到并引导系统了。 8、有时候导入阵列

zds00virtue的博客 2万+

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

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

手把手教你学编程 1万+

共享单车需求预测问题:建模篇

机器学习训练营——机器学习爱好者的自由交流空间(qq群号:696721295) 在上一篇里,我们使用可视化的方法分析了“共享单车”的数据集,理解了特征(变量)之间的关系。我们将在本篇建立几个模型预测单车的需求量,并比较它们的预测效果。 随机森林填充法 首先,导入必需的库、训练集和检验集。 import pylab import calendar import numpy as np impor...

wong2016的博客 1万+

正则表达式常用例子汇总

正则匹配全部汇总: 目录 正则匹配全部汇总: 一、校验数字的表达式 二、校验字符的表达式 三、特殊需求表达式 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万+

从零拆解快手Web端__NS_hxfalcon:JS逆向签名参数定位与复现

在JS逆向与前端反爬攻防中,签名参数总是绕不开的核心环节。无论是接口加密还是请求签名,其本质都是通过在客户端收集环境信息、时间戳与业务参数,经特定算法计算后生成用于服务端校验的动态令牌。理解这类参数的生成原理,不仅能提升逆向分析效率,也能帮助前端开发者更好地设计自身接口防护方案。在实际工程中,面对经Webpack打包且高度混淆的代码,直接全局搜索参数名往往难以奏效,需要结合请求抓包、调用栈跟踪、环境适配等方法逐步定位。此类签名参数广泛存在于现代Web应用的GraphQL或REST接口中,是接口数据安全的重要

weixin_29474431的博客 343

24、交通信号协调算法与模型解析

本文深入解析了交通信号协调中的关键算法与模型,包括多路径进展模型、MAXBAND网络系统模型和松弛启用带模型。这些模型通过合理安排相位序列、优化绿波带宽等方式,提高了交通运行的效率。文章还探讨了交通控制从单点控制向网络协调的发展趋势,分析了当前面临的挑战与机遇,并提出了未来研究方向,如借助信息技术和机器学习,深入研究交通网络的基本构成,以实现智能化和精准化的信号协调。

agile9scrum的博客 136

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

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

前端达人 2779

18、Excel VBA编程:自定义函数创建与代码调试全攻略

本文详细介绍了Excel VBA中自定义函数的创建方法,以获取单元格注释为例演示了完整开发流程,并深入讲解了代码调试的重要性与核心工具。内容涵盖三种主要错误类型及其应对策略,系统介绍了调试工具栏、断点、逐行执行、Locals窗口、Immediate窗口等实用功能。通过综合案例展示了如何运用调试技术解决实际问题,并总结了提前规划、逐步测试、日志记录等最佳实践,帮助读者提升VBA编程效率与代码质量。

life6的博客 102

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

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

君莫笑的博客 2万+

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

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

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

Python绘制小月亮

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

简简单单 5847

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

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

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

Pocker_Spades_A的博客 1064

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

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

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

CSDN 官方博客 5649

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

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

zzywxc787的博客 1137

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

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

weixin_39682940的博客 730

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

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

weixin_47730343的博客 964

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

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

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

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址