10个Python绘画表白代码【内附源码,再不收藏你只能单身了】_有趣的python代码表白(1)

收集整理了一份《2024年最新Python全套学习资料》免费送给大家,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
img
img



既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上Python知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来

如果你需要这些资料,可以添加V无偿获取:hxbc188 (备注666)
img

正文

    else:

        turtle.dot(5)

        Skip(-radius)

    turtle.right(6)

def Week(t):

week = ["星期一", "星期二", "星期三",

        "星期四", "星期五", "星期六", "星期日"]

return week[t.weekday()]

def Date(t):

y = t.year

m = t.month

d = t.day

return "%s %d%d" % (y, m, d)

def Tick():

# 绘制表针的动态显示

t = datetime.today()

second = t.second + t.microsecond \* 0.000001

minute = t.minute + second / 60.0

hour = t.hour + minute / 60.0

secHand.setheading(6 \* second)

minHand.setheading(6 \* minute)

hurHand.setheading(30 \* hour)



turtle.tracer(False) 

printer.forward(65)

printer.write(Week(t), align="center",

              font=("Courier", 14, "bold"))

printer.back(130)

printer.write(Date(t), align="center",

              font=("Courier", 14, "bold"))

printer.home()

turtle.tracer(True)



# 100ms后继续调用tick

turtle.ontimer(Tick, 100)

def main():

# 打开/关闭龟动画,并为更新图纸设置延迟。

turtle.tracer(False)

Init()

SetupClock(160)

turtle.tracer(True)

Tick()

turtle.mainloop()

if name == “__main__”:

main()

### 表白爱心


效果图:  
 ![请添加图片描述](https://img-blog.csdnimg.cn/1fb00023720e41cbaa11e23865148ef9.gif)  
 **源码:**



import turtle
import math
turtle.pen()
t=turtle
t.up()
t.goto(0,150)
t.down()
t.color(‘red’)
t.begin_fill()
t.fillcolor(‘red’)
t.speed(1)
t.left(45)
t.forward(150)
t.right(45)
t.forward(100)
t.right(45)
t.forward(100)
t.right(45)
t.forward(100)
t.right(45)
t.forward(250+math.sqrt(2)*100)
t.right (90)
t.speed(2)
t.forward(250+100*math.sqrt(2))
t.right(45)
t.forward(100)
t.right(45)
t.forward(100)
t.right(45)
t.forward(100)
t.right(45)
t.forward(150)
t.end_fill()
t.goto(-10,0)
t.pencolor(‘white’)
#L
t.pensize(10)
t.goto(-50,0)
t.goto(-50,80)
t.up ()
#I
t.goto(-100,0)
t.down()
t.goto(-160,0)
t.goto(-130,0)
t.goto(-130,80)
t.goto(-160,80)
t.goto(-100,80)
t.up()
#O
t.goto(10,25)
t.down()
t.right(45)
t.circle(25,extent=180)
t.goto(60,55)
t.circle(25,extent=180)
t.goto(10,25)
t.up()
t.goto(75,80)
t.down()
t.goto(100,0)
t.goto(125,80)
t.up()
t.goto(180,80)
t.down()
t.goto(140,80)
t.goto(140,0)
t.goto(180,0)
t.up()
t.goto(180,40)
t.down()
t.goto(140,40)
#U
t.up()
t.goto(-40,-30)
t.down()
t.goto(-40,-80)
t.circle(40,extent=180)
t.goto(40,-30)
t.hideturtle()


### 小猪佩奇


效果图:  
 ![在这里插入图片描述](https://img-blog.csdnimg.cn/881bb220a98a402485cffc2b104f9ca8.gif#pic_center)  
 **源码:**



coding:utf-8

import time
import turtle as t

t.pensize(4)
t.colormode(255)
t.color((255,155,192),“pink”)
t.setup(840,500)
t.speed(10)
t.pu()
t.goto(-100,100)
t.pd()
t.seth(-30)
t.begin_fill()
a=0.4
for i in range(120):
if 0<=i<30 or 60<=i<90:
a=a+0.08
t.lt(3)
t.fd(a)
else:
a=a-0.08
t.lt(3)
t.fd(a)
t.end_fill()
t.pu()
t.seth(90)
t.fd(25)
t.seth(0)
t.fd(10)
t.pd()
t.pencolor(255,155,192)
t.seth(10)
t.begin_fill()
t.circle(5)
t.color(160,82,45)
t.end_fill()
t.pu()
t.seth(0)
t.fd(20)
t.pd()
t.pencolor(255,155,192)
t.seth(10)
t.begin_fill()
t.circle(5)
t.color(160,82,45)
t.end_fill()

t.color((255,155,192),“pink”)
t.pu()
t.seth(90)
t.fd(41)
t.seth(0)
t.fd(0)
t.pd()
t.begin_fill()
t.seth(180)
t.circle(300,-30)
t.circle(100,-60)
t.circle(80,-100)
t.circle(150,-20)
t.circle(60,-95)
t.seth(161)
t.circle(-300,15)
t.pu()
t.goto(-100,100)
t.pd()
t.seth(-30)
a=0.4
for i in range(60):
if 0<=i<30 or 60<=i<90:
a=a+0.08
t.lt(3)
t.fd(a)
else:
a=a-0.08
t.lt(3)
t.fd(a)
t.end_fill()

t.color((255,155,192),“pink”)
t.pu()
t.seth(90)
t.fd(-7)
t.seth(0)
t.fd(70)
t.pd()
t.begin_fill()
t.seth(100)
t.circle(-50,50)
t.circle(-10,120)
t.circle(-50,54)
t.end_fill()
t.pu()
t.seth(90)
t.fd(-12)
t.seth(0)
t.fd(30)
t.pd()
t.begin_fill()
t.seth(100)
t.circle(-50,50)
t.circle(-10,120)
t.circle(-50,56)
t.end_fill()

t.color((255,155,192),“white”)
t.pu()
t.seth(90)
t.fd(-20)
t.seth(0)
t.fd(-95)
t.pd()
t.begin_fill()
t.circle(15)
t.end_fill()
t.color(“black”)
t.pu()
t.seth(90)
t.fd(12)
t.seth(0)
t.fd(-3)
t.pd()
t.begin_fill()
t.circle(3)
t.end_fill()
t.color((255,155,192),“white”)
t.pu()
t.seth(90)
t.fd(-25)
t.seth(0)
t.fd(40)
t.pd()
t.begin_fill()
t.circle(15)
t.end_fill()
t.color(“black”)
t.pu()
t.seth(90)
t.fd(12)
t.seth(0)
t.fd(-3)
t.pd()
t.begin_fill()
t.circle(3)
t.end_fill()
#腮
t.color((255,155,192))
t.pu()
t.seth(90)
t.fd(-95)
t.seth(0)
t.fd(65)
t.pd()
t.begin_fill()
t.circle(30)
t.end_fill()
#嘴
t.color(239,69,19)
t.pu()
t.seth(90)
t.fd(15)
t.seth(0)
t.fd(-100)
t.pd()
t.seth(-80)
t.circle(30,40)
t.circle(40,80)
#身体
t.color(“red”,(255,99,71))
t.pu()
t.seth(90)
t.fd(-20)
t.seth(0)
t.fd(-78)
t.pd()
t.begin_fill()
t.seth(-130)
t.circle(100,10)
t.circle(300,30)
t.seth(0)
t.fd(230)
t.seth(90)
t.circle(300,30)
t.circle(100,3)
t.color((255,155,192),(255,100,100))
t.seth(-135)
t.circle(-80,63)
t.circle(-150,24)
t.end_fill()
#手
t.color((255,155,192))
t.pu()
t.seth(90)
t.fd(-40)
t.seth(0)
t.fd(-27)
t.pd()
t.seth(-160)
t.circle(300,15)
t.pu()
t.seth(90)
t.fd(15)
t.seth(0)
t.fd(0)
t.pd()
t.seth(-10)
t.circle(-20,90)
t.pu()
t.seth(90)
t.fd(30)
t.seth(0)
t.fd(237)
t.pd()
t.seth(-20)
t.circle(-300,15)
t.pu()
t.seth(90)
t.fd(20)
t.seth(0)
t.fd(0)
t.pd()
t.seth(-170)
t.circle(20,90)
#脚
t.pensize(10)
t.color((240,128,128))
t.pu()
t.seth(90)
t.fd(-75)
t.seth(0)
t.fd(-180)
t.pd()
t.seth(-90)
t.fd(40)
t.seth(-180)
t.color(“black”)
t.pensize(15)
t.fd(20)
t.pensize(10)
t.color((240,128,128))
t.pu()
t.seth(90)
t.fd(40)
t.seth(0)
t.fd(90)
t.pd()
t.seth(-90)
t.fd(40)
t.seth(-180)
t.color(“black”)
t.pensize(15)
t.fd(20)
#尾巴
t.pensize(4)
t.color((255,155,192))
t.pu()
t.seth(90)
t.fd(70)
t.seth(0)
t.fd(95)
t.pd()
t.seth(0)
t.circle(60,20)
t.circle(10,230)
t.circle(60,30)


### 多角形太阳花


效果图:  
 ![请添加图片描述](https://img-blog.csdnimg.cn/b3cdb0ab03434ebfa8df49b6d82c5a0d.gif)  
 **源码:**



coding=utf-8

import turtle

import time

同时设置pencolor=color1, fillcolor=color2

turtle.color(“red”, “yellow”)

turtle.begin_fill()

for _ in range(50):

turtle.forward(200)

turtle.left(170)

turtle.end_fill()

turtle.mainloop()


### 进阶自定义表白爱心


效果图:  
 ![在这里插入图片描述](https://img-blog.csdnimg.cn/fe46ec17e201461ba1a67e9f02efbcf2.gif#pic_center)


### 模拟3D星空


效果图:  
 ![请添加图片描述](https://img-blog.csdnimg.cn/51d4df1cc77d4b61a8629142e16bd5a8.gif)


### 超梦幻的蓝色背景樱花


效果图:  
 ![在这里插入图片描述](https://img-blog.csdnimg.cn/2c3e743f0128473db1fbd367149e2fa3.gif#pic_center)


### 花儿


效果图:  
 ![请添加图片描述](https://img-blog.csdnimg.cn/8da3121ce7dd419f8e80d2544005eb2d.gif)


### 表白爱心树


效果图:  
 ![在这里插入图片描述](https://img-blog.csdnimg.cn/0bab184f5b64485c87b942a22d644d03.gif#pic_center)


### 其他


![请添加图片描述](https://img-blog.csdnimg.cn/edd4132bb2674155b63f57c2c96b447f.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBA5bCP55m95YWU55m95Y-I55m9aQ==,size_16,color_FFFFFF,t_70,g_se,x_16)



> 
> **其他源码领取可关注我的公众号:白又白学Python**


### 最后

> **🍅 硬核资料**:关注即可领取PPT模板、简历模板、行业经典书籍PDF。  
> **🍅 技术互助**:技术群大佬指点迷津,你的问题可能不是问题,求资源在群里喊一声。  
> **🍅 面试题库**:由技术群里的小伙伴们共同投稿,热乎的大厂面试真题,持续更新中。  
> **🍅 知识体系**:含编程语言、算法、大数据生态圈组件(Mysql、Hive、Spark、Flink)、数据仓库、Python、前端等等。




**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**

**如果你需要这些资料,可以添加V无偿获取:hxbc188 (备注666)**
![img](https://img-blog.csdnimg.cn/img_convert/e61b097301ec68cdb38a6b86130a333e.png)

**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**
P55m95YWU55m95Y-I55m9aQ==,size_16,color_FFFFFF,t_70,g_se,x_16)



> 
> **其他源码领取可关注我的公众号:白又白学Python**


### 最后

> **🍅 硬核资料**:关注即可领取PPT模板、简历模板、行业经典书籍PDF。  
> **🍅 技术互助**:技术群大佬指点迷津,你的问题可能不是问题,求资源在群里喊一声。  
> **🍅 面试题库**:由技术群里的小伙伴们共同投稿,热乎的大厂面试真题,持续更新中。  
> **🍅 知识体系**:含编程语言、算法、大数据生态圈组件(Mysql、Hive、Spark、Flink)、数据仓库、Python、前端等等。




**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**

**如果你需要这些资料,可以添加V无偿获取:hxbc188 (备注666)**
[外链图片转存中...(img-NH8GdEyr-1713809884423)]

**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值