python告白代码,只属于程序员的浪漫

写在前头:

          慢慢的,程序员这个行业成为大家茶余饭后取乐的无辜群体。只要说到程序员,脑海中就浮现出刻板印象,标配穿搭:格子衫,牛仔裤,黑框眼镜。当然秃顶也是必须的,更狠的吐槽还有邋里邋遢,不懂浪漫,不知人情世故!开始可能只是幽默玩笑,后面慢慢就越传越多,大家便信以为真!可是程序员真的是这样吗?随着现在编程这个行业的普遍高薪收入,程序员又成为大家关注的焦点,深入的了解后,发现程序员其实是很可爱的一个群体。他们有着自己标新立异的想法和活跃的思维,他们用指间汇编着这个精彩的世界。他们有时会很丧,却又很快的充满能量去面对工作和生活,他们有时话会很少,因为他们知道自己肩上的担子很重,他们用双手小心翼翼的呵护着亲人,爱人的幸福。用自己的思维去让这个世界更美好!都说他们不懂浪漫,但你们是否见过他们遇见爱情的样子!

         这世间的美好与你环环相扣,才会让你流连忘返不想远走,有你在的地方那就是尽头,多想安静陪在你左右,就让所有美好与你环环相扣,天涯海角不是我的梦寐以求,一转身就在你的背后!感谢每个在工作岗位默默无闻的程序员,也鼓励那些小猿们,我们都相信我们会为自己的幸福努力奋斗,会让这个世界因为有了我们的故事而更精彩生动!
         
         以下从网上整理了一些告白代码,让我们一起来看看程序员的浪漫吧!只属于程序员的浪漫。

 
 
在这里插入图片描述
 

1.醉美樱花:

在这里插入图片描述
 

import turtle as T
import random
import time

# 画樱花的躯干(60,t)
def Tree(branch, t):
    time.sleep(0.0005)
    if branch > 3:
        if 8 <= branch <= 12:
            if random.randint(0, 2) == 0:
                t.color('snow')  # 白
            else:
                t.color('lightcoral')  # 淡珊瑚色
            t.pensize(branch / 3)
        elif branch < 8:
            if random.randint(0, 1) == 0:
                t.color('snow')
            else:
                t.color('lightcoral')  # 淡珊瑚色
            t.pensize(branch / 2)
        else:
            t.color('sienna')  # 赭(zhě)色
            t.pensize(branch / 10)  # 6
        t.forward(branch)
        a = 1.5 * random.random()
        t.right(20 * a)
        b = 1.5 * random.random()
        Tree(branch - 10 * b, t)
        t.left(40 * a)
        Tree(branch - 10 * b, t)
        t.right(20 * a)
        t.up()
        t.backward(branch)
        t.down()

# 掉落的花瓣
def Petal(m, t):
    for i in range(m):
        a = 200 - 400 * random.random()
        b = 10 - 20 * random.random()
        t.up()
        t.forward(b)
        t.left(90)
        t.forward(a)
        t.down()
        t.color('lightcoral')  # 淡珊瑚色
        t.circle(1)
        t.up()
        t.backward(a)
        t.right(90)
        t.backward(b)

# 绘图区域
t = T.Turtle()
# 画布大小
w = T.Screen()
t.hideturtle()  # 隐藏画笔
t.getscreen().tracer(5, 0)
w.screensize(bg='wheat')  # wheat小麦
t.left(90)
t.up()
t.backward(150)
t.down()
t.color('sienna')

# 画樱花的躯干
Tree(60, t)
# 掉落的花瓣
Petal(200, t)
w.exitonclick()

 
 

2.哆啦A梦

 
在这里插入图片描述
 

import turtle as t

t.bgcolor('peachpuff')

t.speed(10)
t.pensize(8)
t.hideturtle()
t.screensize(500, 500, bg='white')

# 猫脸
t.fillcolor('#00A1E8')
t.begin_fill()
t.circle(120)
t.end_fill()

t.pensize(3)
t.fillcolor('white')
t.begin_fill()
t.circle(100)
t.end_fill()

t.pu()
t.home()
t.goto(0, 134)
t.pd()
t.pensize(4)
t.fillcolor("#EA0014")
t.begin_fill()
t.circle(18)
t.end_fill()

t.pu()
t.goto(7, 155)
t.pensize(2)
t.color('white', 'white')
t.pd()
t.begin_fill()
t.circle(4)
t.end_fill()

t.pu()
t.goto(-30, 160)
t.pensize(4)
t.pd()
t.color('black', 'white')
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)  # 向左转3度
        t.fd(a)  # 向前走a的步长
    else:
        a = a - 0.08
        t.lt(3)
        t.fd(a)
t.end_fill()

t.pu()
t.goto(30, 160)
t.pensize(4)
t.pd()
t.color('black', 'white')
t.begin_fill()
for i in range(120):
    if 0 <= i < 30 or 60 <= i < 90:
        a = a + 0.08
        t.lt(3)  # 向左转3度
        t.fd(a)  # 向前走a的步长
    else:
        a = a - 0.08
        t.lt(3)
        t.fd(a)
t.end_fill()

t.pu()
t.goto(-38, 190)
t.pensize(8)
t.pd()
t.right(-30)
t.forward(15)
t.right(70)
t.forward(15)

t.pu()
t.goto(15, 185)
t.pensize(4)
t.pd()
t.color('black', 'black')
t.begin_fill()
t.circle(13)
t.end_fill()

t.pu()
t.goto(13, 190)
t.pensize(2)
t.pd()
t.color('white', 'white')
t.begin_fill()
t.circle(5)
t.end_fill()

t.pu()
t.home()
t.goto(0, 134)
t.pensize(4)
t.pencolor('black')
t.pd()
t.right(90)
t.forward(40)

t.pu()
t.home()
t.goto(0, 124)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(10)
t.forward(80)

t.pu()
t.home()
t.goto(0, 114)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(6)
t.forward(80)

t.pu()
t.home()
t.goto(0, 104)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(0)
t.forward(80)

# 左边的胡子
t.pu()
t.home()
t.goto(0, 124)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(170)
t.forward(80)

t.pu()
t.home()
t.goto(0, 114)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(174)
t.forward(80)

t.pu()
t.home()
t.goto(0, 104)
t.pensize(3)
t.pencolor('black')
t.pd()
t.left(180)
t.forward(80)

t.pu()
t.goto(-70, 70)
t.pd()
t.color('black', 'red')
t.pensize(6)
t.seth(-60)
t.begin_fill()
t.circle(80, 40)
t.circle(80, 80)
t.end_fill()

t.pu()
t.home()
t.goto(-80, 70)
t.pd()
t.forward(160)

t.pu()
t.home()
t.goto(-50, 50)
t.pd()
t.pensize(1)
t.fillcolor("#eb6e1a")
t.seth(40)
t.begin_fill()
t.circle(-40, 40)
t.circle(-40, 40)
t.seth(40)
t.circle(-40, 40)
t.circle(-40, 40)
t.seth(220)
t.circle(-80, 40)
t.circle(-80, 40)
t.end_fill()

# 领带
t.pu()
t.goto(-70, 12)
t.pensize(14)
t.pencolor('red')
t.pd()
t.seth(-20)
t.circle(200, 30)
t.circle(200, 10)

# 铃铛
t.pu()
t.goto(0, -46)
t.pd()
t.pensize(3)
t.color("black", '#f8d102')
t.begin_fill()
t.circle(25)
t.end_fill()

t.pu()
t.goto(-5, -40)
t.pd()
t.pensize(2)
t.color("black", '#79675d')
t.begin_fill()
t.circle(5)
t.end_fill()

t.pensize(3)
t.right(115)
t.forward(7)

t.mainloop()

 
 

5.深情桃花

 
在这里插入图片描述
 


import turtle
import random

turtle.bgcolor('peachpuff')


#在(x,y)处画爱心
def love(x,y):
    lv=turtle.Turtle()

    lv.hideturtle()

    lv.up()

    # 定位到(x,y)
    lv.goto(x,y)

    # 画圆弧
    def curvemove():
        for i in range(20):
            lv.right(10)
            lv.forward(2)
    lv.color('red','pink')

    lv.speed(10000000)

    lv.pensize(1)

    #开始画爱心

    lv.down()

    lv.begin_fill()

    lv.left(140)

    lv.forward(22)

    curvemove()

    lv.left(120)

    curvemove()

    lv.forward(22)

    lv.write("桃花",font=("Arial",12,"normal"),align="center")

    lv.left(140)#画完复位

    lv.end_fill()

def tree(branchLen,t):
    if branchLen > 5:#剩余树枝太少要结束递归
        if branchLen<20:

            t.color("green")

            t.pensize(random.uniform((branchLen + 5) / 4 - 2, (branchLen + 6) / 4 + 5))

            t.down()

            t.forward(branchLen)

            love(t.xcor(),t.ycor())#传输现在turtle的坐标

            t.up()

            t.backward(branchLen)
            t.color("brown")

            return

        t.pensize(random.uniform((branchLen + 5) / 4 - 2, (branchLen + 6) / 4 + 5))

        t.down()

        t.forward(branchLen)

        # 以下递归

        ang = random.uniform(15, 45)

        t.right(ang)

        tree(branchLen - random.uniform(12, 16), t)  # 随机决定减小长度

        t.left(2 * ang)

        tree(branchLen - random.uniform(12, 16), t)  # 随机决定减小长度

        t.right(ang)

        t.up()

        t.backward(branchLen)


myWin = turtle.Screen()

t = turtle.Turtle()

t.hideturtle()

t.speed(10000)

t.left(90)

t.up()

t.backward(200)

t.down()

t.color("brown")

t.pensize(32)

t.forward(60)

tree(100, t)

myWin.exitonclick()

 
 

6.一箭穿心

 
在这里插入图片描述

import turtle
import time
def hart_arc():
    for i in range(200):
        turtle.right(1)
        turtle.forward(2)

def move_pen_position(x, y):
    turtle.hideturtle()  # 隐藏画笔(先)
    turtle.up()  # 提笔
    turtle.goto(x, y)  # 移动画笔到指定起始坐标(窗口中心为0,0)
    turtle.down()  # 下笔
    turtle.showturtle()  # 显示画笔


love = input("请输入表白话语:")
signature = input("请签署你的名字:")
date=input("请写上日期:")

if love == '':
    love = 'I Love You'
turtle.setup(width=800, height=500)  # 窗口(画布)大小
turtle.color('red', 'pink')  # 画笔颜色
turtle.pensize(3)  # 画笔粗细
turtle.speed(1)  # 描绘速度
# 初始化画笔起始坐标
move_pen_position(x=0, y=-180)  # 移动画笔位置
turtle.left(140)  # 向左旋转140度

turtle.begin_fill()  # 标记背景填充位置

turtle.forward(224)  # 向前移动画笔,长度为224
# 画爱心圆弧
hart_arc()  # 左侧圆弧
turtle.left(120)  # 调整画笔角度
hart_arc()  # 右侧圆弧
# 画心形直线( 右下方 )
turtle.forward(224)

turtle.end_fill()  # 标记背景填充结束位置

move_pen_position(x=70, y=160)  # 移动画笔位置
turtle.left(185)  # 向左旋转180度
turtle.circle(-110,185)  # 右侧圆弧
# 画心形直线( 右下方 )
#turtle.left(20)  # 向左旋转180度
turtle.forward(50)
move_pen_position(x=-180, y=-180)  # 移动画笔位置
turtle.left(180)  # 向左旋转140度

# 画心形直线( 左下方 )
turtle.forward(600)  # 向前移动画笔,长度为224

# 在心形中写上表白话语
move_pen_position(0,50)  # 表白语位置
turtle.hideturtle()  # 隐藏画笔
turtle.color('#CD5C5C', 'pink')  # 字体颜色
# font:设定字体、尺寸(电脑下存在的字体都可设置)  align:中心对齐
turtle.write(love, font=('Arial', 20, 'bold'), align="center")

# 签写署名和日期
if (signature != '') & (date != ''):
    turtle.color('red', 'pink')
    time.sleep(2)
    move_pen_position(220, -180)
    turtle.hideturtle()  # 隐藏画笔
    turtle.write(signature, font=('Arial', 20), align="center")
    move_pen_position(220, -220)
    turtle.hideturtle()  # 隐藏画笔
    turtle.write(date, font=('Arial', 20), align="center")

#1-5点击窗口关闭程序
window = turtle.Screen()
window.exitonclick()

 
 

            记得点赞哦!

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_43697214/article/details/103102027