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

一、前言

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

嫦娥飞天去,神州归来也

在文章开始前打个小广告——分享一份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%免费

在这里插入图片描述

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值