用Python Turtle绘制天安门技术讲解

news2024/10/7 21:52:58

概述

Python的Turtle模块是一个简单的绘图库,它允许用户通过简单的命令控制一个小海龟在屏幕上移动,绘制出各种图形。本文将通过一个具体的示例——绘制简化版的天安门,来详细讲解如何使用Turtle模块。

环境准备

确保你的Python环境中已经安装了Turtle模块。大多数Python安装包已经自带了这个模块,如果没有,可以通过以下命令安装:

pip install PythonTurtle

效果图

在这里插入图片描述

Turtle模块基础

Turtle模块提供了一个绘图板(Screen)和一个画笔(Turtle),画笔可以在绘图板上移动并绘制图形。

基本命令

  • t.penup():提起画笔,移动时不绘制。
  • t.pendown():放下画笔,移动时绘制。
  • t.goto(x, y):将画笔移动到坐标(x, y)。
  • t.left(angle):画笔左转angle度。
  • t.right(angle):画笔右转angle度。
  • t.circle(radius, extent):画笔画圆,radius为半径,extent为圆弧角度。
  • t.begin_fill():开始填充颜色。
  • t.end_fill():结束填充颜色。

绘制天安门

以下是使用Turtle模块绘制简化版天安门的代码,我们将逐步分析代码的每个部分。

初始化设置

import turtle as t

t.hideturtle()  # 隐藏画笔的箭头
t.setup(width=0.9, height=0.9)  # 设置绘图窗口的大小
t.speed(5)  # 设置画笔的移动速度
t.pensize(1)  # 设置画笔的粗细
t.setx(0)  # 设置画笔的x坐标
t.sety(0)  # 设置画笔的y坐标

绘制天安门的基座

t.begin_fill()
t.fillcolor((0.8705, 0.0784, 0.0784))  # 设置填充颜色
t.goto(-250, 0)
t.goto(-223.55, 150)
t.goto(223.55, 150)
t.goto(250, 0)
t.goto(0, 0)
t.end_fill()

绘制门

# 绘制五个门,每个门的代码类似,这里只展示一个
t.begin_fill()
t.fillcolor("black")
t.goto(20, 0)
t.goto(20, 40)
t.right(270)
t.circle(20, 180)
t.goto(-20, 0)
t.goto(0, 0)
t.end_fill()

绘制文字

t.penup()
t.fillcolor((0.929, 0.180, 0.180))  # 设置填充颜色
t.goto(-177, 137)
t.pendown()
t.begin_fill()
t.goto(-63, 137)
t.goto(-63, 123)
t.goto(-177, 123)
t.goto(-177, 137)
t.end_fill()
t.penup()
t.goto(-177, 123)
t.pendown()
t.color("white")
t.write("中华人民共和国万岁", align="left", font=("华文中宋", "10", "normal"))
t.color("black")

绘制灯笼

t.penup()
t.goto(-135, 172)
t.pendown()
t.fillcolor((0.8705, 0.0784, 0.0784))
t.begin_fill()
t.setheading(90)
for k in range(2):
    len = 0.2
    for i in range(60):
        if i < 30:
            len += 0.01
        if i > 30:
            len -= 0.01
        t.fd(len)
        t.left(3)
t.end_fill()

绘制地面

t.penup()
t.fillcolor((0.8705, 0.0784, 0.0784))
t.goto(0, 151)
t.pendown()
t.begin_fill()
t.goto(160, 151)
t.goto(160, 185.63)
t.goto(-160, 185.63)
t.goto(-160, 151)
t.goto(0, 151)
t.end_fill()

完成绘制

t.exitonclick()  # 点击窗口关闭程序

完整代码

import turtle as t

t.hideturtle()
t.setup(width=0.9,height=0.9,startx=None,starty=None)
t.speed(5)
t.pensize(1)
t.setx(0)
t.sety(0)

###base###
t.begin_fill()
t.fillcolor(0.8705,0.0784,0.0784)
t.goto(-250,0)
t.goto(-223.55,150)
t.goto(223.55,150)
t.goto(250,0)
t.goto(0,0)
t.end_fill()

##door1#
t.begin_fill()
t.fillcolor("black")
t.goto(20,0)
t.goto(20,40)
t.right(270)
t.circle(20,180)
t.goto(-20,0)
t.goto(0,0)
t.end_fill()

##door2##
t.begin_fill()
t.fillcolor("black")
t.right(90)
t.goto(-50,0)
t.goto(-50,30)
t.right(90)
t.circle(15,180)
t.goto(-80,0)
t.goto(0,0)
t.end_fill()

##door3##
t.begin_fill()
t.fillcolor("black")
t.right(90)
t.goto(-105,0)
t.goto(-105,30)
t.right(90)
t.circle(15,180)
t.goto(-135,0)
t.goto(0,0)
t.end_fill()

##door4##
t.begin_fill()
t.fillcolor("black")
t.right(90)
t.goto(80,0)
t.goto(80,30)
t.right(90)
t.circle(15,180)
t.goto(50,0)
t.goto(0,0)
t.end_fill()

##door5##
t.begin_fill()
t.fillcolor("black")
t.right(90)
t.goto(135,0)
t.goto(135,30)
t.right(90)
t.circle(15,180)
t.goto(105,0)
t.goto(0,0)
t.end_fill()

##under##
t.penup()
t.goto(-249.12,5)
t.pendown()
t.begin_fill()
t.fillcolor("yellow")
t.goto(-249.12,5)
t.goto(249.12,5)
t.goto(250,0)
t.goto(-250,0)
t.goto(-249.12,5)
t.end_fill()

##up##
t.penup()
t.goto(-224.43,145)
t.pendown()
t.begin_fill()
t.fillcolor("yellow")
t.goto(224.43,145)
t.goto(223.55,150)
t.goto(-223.55,150)
t.end_fill()

##leftword##
t.penup()
t.fillcolor(0.9372,0.9294,0.9294)
t.goto(-180,140)
t.pendown()
t.begin_fill()
t.goto(-60,140)
t.goto(-60,120)
t.goto(-180,120)
t.goto(-180,140)
t.goto(-180,120)
t.end_fill()
t.penup()
t.fillcolor(0.929,0.180,0.180)
t.goto(-177,137)
t.pendown()
t.begin_fill()
t.goto(-63,137)
t.goto(-63,123)
t.goto(-177,123)
t.goto(-177,137)
t.end_fill()
t.penup()
t.goto(-177,123)
t.pendown()
t.color("white")
t.write("中华人民共和国万岁",align="left",font=("华文中宋","10","normal"))
t.color("black")

##rightword##
t.penup()
t.fillcolor(0.9372,0.9294,0.9294)
t.goto(180,140)
t.pendown()
t.begin_fill()
t.goto(60,140)
t.goto(60,120)
t.goto(180,120)
t.goto(180,140)
t.goto(180,120)
t.end_fill()
t.penup()
t.fillcolor(0.929,0.180,0.180)
t.goto(177,137)
t.pendown()
t.begin_fill()
t.goto(63,137)
t.goto(63,123)
t.goto(177,123)
t.goto(177,137)
t.end_fill()
t.penup()
t.goto(63,123)
t.pendown()
t.color("white")
t.write("世界人民大团结万岁",align="left",font=("华文中宋","10","normal"))
t.color("black")

##face##
t.penup()
t.goto(-25,140)
t.pendown()
t.begin_fill()
t.fillcolor(0.9647,0.71764,0.04313)
t.goto(25,140)
t.goto(25,80)
t.goto(-25,80)
t.goto(-25,140)
t.end_fill()
t.penup()
t.goto(-23,138)
t.pendown()
t.begin_fill()
t.fillcolor(0.9686,0.8078,0.36862)
t.goto(23,138)
t.goto(23,83)
t.goto(-23,83)
t.goto(-23,137)
t.end_fill()

###floor##
t.penup()
t.fillcolor(0.8705,0.0784,0.0784)
t.goto(0,151)
t.pendown()
t.begin_fill()
t.goto(160,151)
t.goto(160,185.63)
t.goto(-160,185.63)
t.goto(-160,151)
t.goto(0,151)
t.end_fill()
##on door1##
t.penup()
t.goto(-155,150)
t.fillcolor(0.6705,0.0588,0.0588)
t.pendown()
t.left(90)
t.begin_fill()
t.left(90)
t.fd(25)
t.right(90)
t.circle(5,90)
t.right(90)
t.fd(15)
t.right(90)
t.circle(5,90)
t.right(90)
t.fd(25)
t.right(90)
t.fd(25)
t.end_fill()
t.penup()
t.fillcolor("yellow")
t.begin_fill()
t.goto(-147,180)
t.pendown()
t.left(180)
for i in range(2):
    t.fd(9)
    t.right(90)
    t.fd(2)
    t.right(90)
t.end_fill()
###lantern##
t.penup()
t.goto(-135,172)
t.pendown()
t.fillcolor(0.8705,0.0784,0.0784)
t.begin_fill()
t.setheading(90)
for k in range(2):
    len=0.2
    for i in range(60):
       if i < 30:
           len +=0.01
       if i >30:
           len -=0.01
       t.fd(len)
       t.left(3)
t.end_fill()
t.penup()
t.goto(-147,165)
t.fillcolor("yellow")
t.pendown()
t.begin_fill()
t.right(90)
for i in range(2):
    t.fd(8)
    t.right(90)
    t.fd(10)
    t.right(90)
t.end_fill()

##on door2##
t.penup()
t.fillcolor(0.6705,0.0588,0.0588)
t.begin_fill()
t.goto(-110,150)
t.pendown()
t.left(90)
t.fd(25)
t.right(90)
t.circle(5,90)
t.right(90)
t.fd(15)
t.right(90)
t.circle(5,90)
t.right(90)
t.fd(25)
t.right(90)
t.fd(25)
t.end_fill()
t.penup()
t.fillcolor("yellow")
t.begin_fill()
t.goto(-102,180)
t.pendown()
t.left(180)
for i in range(2):
    t.fd(9)
    t.right(90)
    t.fd(2)
    t.right(90)
t.end_fill()
###lantern##
t.penup()
t.goto(-90,172)
t.pendown()
t.fillcolor(0.8705,0.0784,0.0784)
t.begin_fill()
t.setheading(90)
for k in range(2):
    len=0.2
    for i in range(60):
       if i < 30:
           len +=0.01
       if i >30:
           len -=0.01
       t.fd(len)
       t.left(3)
t.end_fill()
t.penup()
t.goto(-102,165)
t.fillcolor("yellow")
t.pendown()
t.begin_fill()
t.right(90)
for i in range(2):
    t.fd(8)
    t.right(90)
    t.fd(10)
    t.right(90)
t.end_fill()

##on door3##
t.penup()
t.fillcolor(0.6705,0.0588,0.0588)
t.goto(-65,150)
t.pendown()
t.begin_fill()
t.left(90)
t.fd(25)
t.right(90)
t.circle(5,90)
t.right(90)
t.fd(15)
t.right(90)
t.circle(5,90)
t.right(90)
t.fd(25)
t.right(90)
t.fd(25)
t.end_fill()
t.penup()
t.fillcolor("yellow")
t.begin_fill()
t.goto(-56.5,180)
t.pendown()
t.left(180)
for i in range(2):
    t.fd(9)
    t.right(90)
    t.fd(2)
    t.right(90)
t.end_fill()
###lantern##
t.penup()
t.goto(-45,172)
t.pendown()
t.fillcolor(0.8705,0.0784,0.0784)
t.begin_fill()
t.setheading(90)
for k in range(2):
    len=0.2
    for i in range(60):
       if i < 30:
           len +=0.01
       if i >30:
           len -=0.01
       t.fd(len)
       t.left(3)
t.end_fill()
t.penup()
t.goto(-56.5,165)
t.fillcolor("yellow")
t.pendown()
t.begin_fill()
t.right(90)
for i in range(2):
    t.fd(8)
    t.right(90)
    t.fd(10)
    t.right(90)
t.end_fill()

###door 4##
t.penup()
t.fillcolor(0.6705,0.0588,0.0588)
t.goto(-20,150)
t.pendown()
t.begin_fill()
t.left(90)
t.fd(25)
t.right(90)
t.circle(5,90)
t.right(90)
t.fd(30)
t.right(90)
t.circle(5,90)
t.right(90)
t.fd(25)
t.right(90)
t.fd(25)
t.end_fill()

##on door5##
t.penup()
t.fillcolor(0.6705,0.0588,0.0588)
t.pendown()
t.begin_fill()
t.goto(130,150)
t.right(90)
t.fd(25)
t.right(90)
t.circle(5,90)
t.right(90)
t.fd(15)
t.right(90)
t.circle(5,90)
t.right(90)
t.fd(25)
t.right(90)
t.fd(25)
t.end_fill()
t.penup()
t.fillcolor("yellow")
t.begin_fill()
t.goto(138.5,180)
t.pendown()
t.left(180)
for i in range(2):
    t.fd(9)
    t.right(90)
    t.fd(2)
    t.right(90)
t.end_fill()
###lantern##
t.penup()
t.goto(150,172)
t.pendown()
t.fillcolor(0.8705,0.0784,0.0784)
t.begin_fill()
t.setheading(90)
for k in range(2):
    len=0.2
    for i in range(60):
       if i < 30:
           len +=0.01
       if i >30:
           len -=0.01
       t.fd(len)
       t.left(3)
t.end_fill()
t.penup()
t.goto(138.5,165)
t.fillcolor("yellow")
t.pendown()
t.begin_fill()
t.right(90)
for i in range(2):
    t.fd(8)
    t.right(90)
    t.fd(10)
    t.right(90)
t.end_fill()

##on door4##
t.penup()
t.fillcolor(0.6705,0.0588,0.0588)
t.begin_fill()
t.goto(85,150)
t.pendown()
t.left(90)
t.fd(25)
t.right(90)
t.circle(5,90)
t.right(90)
t.fd(15)
t.right(90)
t.circle(5,90)
t.right(90)
t.fd(25)
t.right(90)
t.fd(25)
t.end_fill()
t.penup()
t.fillcolor("yellow")
t.begin_fill()
t.goto(93.5,180)
t.pendown()
t.left(180)
for i in range(2):
    t.fd(9)
    t.right(90)
    t.fd(2)
    t.right(90)
t.end_fill()
###lantern##
t.penup()
t.goto(105,172)
t.pendown()
t.fillcolor(0.8705,0.0784,0.0784)
t.begin_fill()
t.setheading(90)
for k in range(2):
    len=0.2
    for i in range(60):
       if i < 30:
           len +=0.01
       if i >30:
           len -=0.01
       t.fd(len)
       t.left(3)
t.end_fill()
t.penup()
t.goto(93.5,165)
t.fillcolor("yellow")
t.pendown()
t.begin_fill()
t.right(90)
for i in range(2):
    t.fd(8)
    t.right(90)
    t.fd(10)
    t.right(90)
t.end_fill()
##on door6##
t.penup()
t.fillcolor(0.6705,0.0588,0.0588)
t.goto(40,150)
t.pendown()
t.begin_fill()
t.left(90)
t.fd(25)
t.right(90)
t.circle(5,90)
t.right(90)
t.fd(15)
t.right(90)
t.circle(5,90)
t.right(90)
t.fd(25)
t.right(90)
t.fd(25)
t.end_fill()
t.penup()
t.fillcolor("yellow")
t.begin_fill()
t.goto(48.5,180)
t.pendown()
t.left(180)
for i in range(2):
    t.fd(9)
    t.right(90)
    t.fd(2)
    t.right(90)
t.end_fill()
###lantern##
t.penup()
t.goto(60,172)
t.pendown()
t.fillcolor(0.8705,0.0784,0.0784)
t.begin_fill()
t.setheading(90)
for k in range(2):
    len=0.2
    for i in range(60):
       if i < 30:
           len +=0.01
       if i >30:
           len -=0.01
       t.fd(len)
       t.left(3)
t.end_fill()
t.penup()
t.goto(48.5,165)
t.fillcolor("yellow")
t.pendown()
t.begin_fill()
t.right(90)
for i in range(2):
    t.fd(8)
    t.right(90)
    t.fd(10)
    t.right(90)
t.end_fill()

###floor up##
t.penup()
t.goto(0,185)
t.pendown()
t.fillcolor(0.6705,0.0588,0.0588)
t.begin_fill()
t.goto(180,185)
t.goto(190,195)
t.goto(-190,195)
t.goto(-180,185)
t.goto(0,185)
t.end_fill()

##floor upup##
t.penup()
t.goto(0,195)
t.begin_fill()
t.fillcolor(0.9568,0.53333,0.2470)
t.pendown()
t.goto(190,195)
t.goto(190,195+14.7)
t.goto(187.73,195+11.94)
t.goto(147.88,195+15.42)
t.goto(-147.88,195+15.42)
t.goto(-187.73,195+11.94)
t.goto(-190,195+14.7)
t.goto(-190,195)
t.goto(0,195)
t.end_fill()

##floor2 under###
t.penup()
t.goto(0,211)
t.pendown()
t.fillcolor(0.4705,0.8431,0.4117)
t.begin_fill()
t.goto(130,211)
t.goto(130,220)
t.goto(-130,220)
t.goto(-130,211)
t.goto(0,211)
t.end_fill()
##floor2##
t.penup()
t.goto(0,221)
t.pendown()
t.fillcolor(0.6705,0.0588,0.0588)
t.begin_fill()
t.goto(140,221)
t.goto(150,230)
t.goto(-150,230)
t.goto(-140,221)
t.goto(0,221)
t.end_fill()

##country##
t.penup()
t.goto(0,206.5)
t.fillcolor(0.9803,0.9490,0.03137)
t.pendown()
t.begin_fill()
t.circle(8,360)
t.end_fill()
t.penup()
t.goto(0,208)
t.fillcolor(0.6705,0.0588,0.0588)
t.pendown()
t.begin_fill()
t.circle(6,360)
t.end_fill()
##floor2 up##
t.penup()
t.goto(0,230)
t.begin_fill()
t.fillcolor(0.9568,0.53333,0.2470)
t.pendown()
t.goto(150,230)
t.goto(150,240)
t.goto(130.08,242.37)
t.goto(130.08,277.37)
t.goto(127.28,273.77)
t.goto(124.23,150+125.51)
t.goto(121.5,265.23)
t.goto(-121.5,265.23)
t.goto(-124.23,150+125.51)
t.goto(-127.28,273.77)
t.goto(-130.08,277.37)
t.goto(-130.08,242.37)
t.goto(-150,240)
t.goto(-150,230)
t.goto(0,230)
t.end_fill()

t.exitonclick()

总结

通过上述步骤,我们使用Python的Turtle模块绘制了一个简化版的天安门。这个过程中,我们学习了Turtle模块的基本命令,包括如何控制画笔的移动、绘制图形、填充颜色以及绘制文本。希望这个示例能够帮助你更好地理解Turtle模块的使用。

进一步探索

  • 尝试修改颜色和形状,绘制不同的建筑或图案。
  • 学习更多Turtle模块的高级功能,如自定义形状、动画等。

通过实践,你可以更深入地掌握Python编程和Turtle绘图库的使用。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2194960.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【CF2021E】Digital Village(All Version)

题目 给你一张 n n n 个点 m m m 条边的无向图&#xff0c;有 p p p 个关键点。你需要选择 k k k 个点染黑&#xff0c;使得这 p p p 个关键点到这 k k k 个黑点的代价和最小。定义代价为两点之间边权最大的边的最小值。 你需要求出 k 1,2,…,n 的所有答案 E1 n,m,p&l…

OBOO鸥柏丨数字化展厅液晶拼接屏联动展馆触摸屏查询一体机信息化

在OBOO鸥柏精心雕琢的多媒体展厅展馆解决方案中&#xff0c;鸥柏液晶拼接屏的多屏联动互动技术犹如一条无形的数字科技纽带&#xff0c;OBOO鸥柏巧妙地将多台商用显示设备编织成一幅幅动态共生的视觉盛宴。鸥柏这项技术&#xff0c;不仅仅是简单的显示设备互联&#xff0c;鸥柏…

73.【C语言】C/C++的内存区域划分

1.内存里的几个区域 除了耳熟能详的栈区,堆区,静态区,还有内核空间,内存映射段,数据段,代码段 2.示意图 3.解释 栈区(stack area):局部变量,函数参数,返回数据,返回地址 内存映射段:将文件映射到内存 映射: 如果看过王爽老师的 《汇编语言 第四版》,其中写到了可以操作B800…

【可答疑】基于51单片机的倒车雷达测距(含仿真、代码、报告、演示视频等)

✨哈喽大家好&#xff0c;这里是每天一杯冰美式oh&#xff0c;985电子本硕&#xff0c;大厂嵌入式在职0.3年&#xff0c;业余时间做做单片机小项目&#xff0c;有需要也可以提供就业指导&#xff08;免费&#xff09;~ &#x1f431;‍&#x1f409;这是51单片机毕业设计100篇…

三、数据链路层(下)

目录 3.6以太网 以太网的分类 Mac地址 以太网数据格式 3.7互联网 数据是如何传输的&#xff1f; 3.8以太网、局域网、互联网的区别 总结&#xff1a; 3.9 vlan基本概念与基本原理 Vlan实现 划分 VLAN 例题 3.10广域网及相关协议 ppp协议 PPP协议所满足的要求 P…

【GitHub】上传文件到GitHub

参考视频&#xff1a;手把手教你在github上传文件_哔哩哔哩_bilibili 1.找到文件夹右键&#xff0c;选择open git bash here 2.完成指令 git initgit add *git commit -m "first commit"3.打开该文件夹&#xff0c;打开隐藏文件.git/config 编辑输入邮箱和GitHub用…

关于Qt音乐播放器进度条拖拽无用的问题解决方案

在使用Qt编写音乐播放器的时候&#xff0c;进度条关联播放音乐基本是必须的。那么在设计的过程中你可能会碰到一个奇怪的问题就是拖拽进度条的时候&#xff0c;可能会报错如下&#xff1a; 然后音乐就卡着不动了。。。 connect(ui->volume_toolButton,&VolumeToolBtn::…

AI大模型,但是在卫星

B站&#xff1a;啥都会一点的研究生公众号&#xff1a;啥都会一点的研究生 AI圈又发生了啥新鲜事&#xff1f; 国星宇航实现全球首次卫星在轨AI大模型技术验证 国星宇航成功完成了全球首次卫星在轨运行AI大模型技术验证&#xff0c;验证了AI大模型在太空中的空间适应性和算力…

解决ERR_PROXY_CONNECTION_FAILED

版权声明 本文原创作者&#xff1a;谷哥的小弟作者博客地址&#xff1a;http://blog.csdn.net/lfdfhl 错误描述 电脑无法正常上网&#xff0c;报错信息如下&#xff1a;ERR_PROXY_CONNECTION_FAILED&#xff1b;图示如下&#xff1a; 解决方案 请按如下步骤和方式解决该问题…

Linux 系统成为隐秘“Perfctl”加密挖矿恶意软件的目标

Aqua Security 的研究人员上周透露&#xff0c;数以千计的 Linux 系统可能感染了极难追踪且持久的“perfctl”&#xff08;或“ perfcc ”&#xff09;加密挖掘恶意软件&#xff0c;许多其他系统仍然面临被入侵的风险。 在观察到的所有攻击中&#xff0c;恶意软件都被用来运行…

C语言入门指南:为大一新生准备

C语言入门指南&#xff1a;为大一新生准备 C语言是许多编程语言的基础&#xff0c;许多现代编程语言&#xff08;如C、Java、Rust等&#xff09;都从C语言中汲取了灵感。因此&#xff0c;学习C语言不仅能帮助你掌握编程的基本概念&#xff0c;还能为学习其他编程语言打下坚实的…

ThinkBook 16+ 锐龙6800h 安装ubuntu键盘失灵

问题&#xff1a;在ThinkBook 16 锐龙6800h 安装ubuntu18.04 出现笔记本键盘按下延迟非常高&#xff0c;输出卡死的情况&#xff0c;但是外接键盘可以正常使用 解决&#xff1a;更新内核 1、进入 https://kernel.ubuntu.com/~kernel-ppa/mainline/ 下载所需内核版本&#x…

Array类、引用类型

前面我们对数组的增加,删除,查找,更改都需要进行循环遍历,非常的麻烦。C#系统为我们提供了Array类,在这个类中定义了许多对数组进行操作的方法,我们可以直接用,从而提高效率。 索引查找: int[] a = { 1, 2, 3, 4, 3 }; int b=Array.IndexOf(a, 3);//第一个参数为数组…

判断是否为二叉排序树(二叉搜索树,二叉查找树)

1.判断给定的二叉树是否为二叉排序树&#xff0c;如果是返回1&#xff0c;不是返回0。 思想&#xff1a; 二叉树是左子树<根<右子树。中序遍历是递增有序&#xff0c;可以通过比较当前结点与前驱关系来进行判断。 代码&#xff1a; //pre为全局变量&#xff0c;保存当…

xmltodict 处理 XML 数据案例解析

简介&#xff1a;xmltodict 是一个用于将 XML 数据转换为 Python 字典的轻量级模块。它简化了 XML 数据的解析和处理&#xff0c;使得在 Python 中操作 XML 变得更加直观和方便。这个模块适合用于数据交换、配置文件解析等需要 XML 数据处理的场景。 历史攻略&#xff1a; loc…

软件验证与确认实验三-数据驱动测试

目录 1. 实验目的及要求.................................................................................................... 3 2. 实验软硬件环境.................................................................................................... 3 …

ASP.NetCore---I18n(internationalization)多语言版本的应用

文章目录 0.实现的效果如下1.创建新项目I18nBaseDemo2.添加页面中的下拉框3.在HomeController中添加ChangeLanguage方法4.在Progress.cs 文件中添加如下代码&#xff1a;5. 在progress.cs中添加code6.添加Resource资源文件7.在页面中引用i18n的变量8. 重启项目&#xff0c;应该…

【多线程】详解 CAS 机制

&#x1f970;&#x1f970;&#x1f970;来都来了&#xff0c;不妨点个关注叭&#xff01; &#x1f449;博客主页&#xff1a;欢迎各位大佬!&#x1f448; 文章目录 1. CAS 是什么1.1 CAS 具体步骤1.2 CAS 伪代码 2. CAS 的应用2.1 实现原子类2.1.1 AtomInteger 类2.1.2 伪代…

【2024最新】基于springboot+vue的教师人事档案管理系统lw+ppt

作者&#xff1a;计算机搬砖家 开发技术&#xff1a;SpringBoot、php、Python、小程序、SSM、Vue、MySQL、JSP、ElementUI等&#xff0c;“文末源码”。 专栏推荐&#xff1a;SpringBoot项目源码、Vue项目源码、SSM项目源码、微信小程序源码 精品专栏&#xff1a;Java精选实战项…

wxPython中wx.ListCtrl用法(样式和事件)

wx.ListCtrl是一个列表组件&#xff0c;可以以列表视图&#xff08;list view&#xff09;、报表视图&#xff08;report view&#xff09;、图标视图&#xff08;icon view&#xff09;和小图标视图&#xff08;small icon view&#xff09;等多种模式显示列表。 组件样式 wx…