520用代码捕获女神芳心_"for item in os

最后的话

最近很多小伙伴找我要Linux学习资料,于是我翻箱倒柜,整理了一些优质资源,涵盖视频、电子书、PPT等共享给大家!

资料预览

给大家整理的视频资料:

给大家整理的电子书资料:

如果本文对你有帮助,欢迎点赞、收藏、转发给朋友,让我有持续创作的动力!

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

需要这份系统化的资料的朋友,可以点击这里获取!

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


**效果图**


![](https://imgconvert.csdnimg.cn/aHR0cHM6Ly9tbWJpei5xcGljLmNuL21tYml6X2dpZi9jYkNMZ2ZKWmlicHF4d213YlhlQXNsaWNBMWljaWJoaWJubDF1aGxqRlB0RGxLeGRpY2IzbklpYllobWdhbUhmM2w3bUtoSGF0NHNsZGliZm5vT3VZV25tRXFyNnlnLzY0MA?x-oss-process=image/format,png)
**二、进阶级**


#### 1、 用turtle库画一朵玫瑰花



#!/usr/bin/env python

coding: utf-8

#绘制玫瑰花并添加文字
import turtle

设置画布大小

turtle.screensize(canvwidth=None, canvheight=None, bg=None)

turtle.setup(width=0.6, height=0.6)

设置初始位置

turtle.penup()
turtle.left(90)
turtle.fd(200)
turtle.pendown()
turtle.right(90)

输出文字

printer = turtle.Turtle()
printer.hideturtle()
printer.penup()
printer.back(200)
printer.write(“赠给亲爱的 XX\n\n”, align=“right”, font=(“楷体”, 16, “bold”))
printer.write(“from XXX”, align=“center”, font=(“楷体”, 12, “normal”))

花蕊

turtle.fillcolor(“red”)
turtle.begin_fill()
turtle.circle(10, 180)
turtle.circle(25, 110)
turtle.left(50)
turtle.circle(60, 45)
turtle.circle(20, 170)
turtle.right(24)
turtle.fd(30)
turtle.left(10)
turtle.circle(30, 110)
turtle.fd(20)
turtle.left(40)
turtle.circle(90, 70)
turtle.circle(30, 150)
turtle.right(30)
turtle.fd(15)
turtle.circle(80, 90)
turtle.left(15)
turtle.fd(45)
turtle.right(165)
turtle.fd(20)
turtle.left(155)
turtle.circle(150, 80)
turtle.left(50)
turtle.circle(150, 90)
turtle.end_fill()

花瓣1

turtle.left(150)
turtle.circle(-90, 70)
turtle.left(20)
turtle.circle(75, 105)
turtle.setheading(60)
turtle.circle(80, 98)
turtle.circle(-90, 40)

花瓣2

turtle.left(180)
turtle.circle(90, 40)
turtle.circle(-80, 98)
turtle.setheading(-83)

叶子1

turtle.fd(30)
turtle.left(90)
turtle.fd(25)
turtle.left(45)
turtle.fillcolor(“green”)
turtle.begin_fill()
turtle.circle(-80, 90)
turtle.right(90)
turtle.circle(-80, 90)
turtle.end_fill()
turtle.right(135)
turtle.fd(60)
turtle.left(180)
turtle.fd(85)
turtle.left(90)
turtle.fd(80)

叶子2

turtle.right(90)
turtle.right(45)
turtle.fillcolor(“green”)
turtle.begin_fill()
turtle.circle(80, 90)
turtle.left(90)
turtle.circle(80, 90)
turtle.end_fill()
turtle.left(135)
turtle.fd(60)
turtle.left(180)
turtle.fd(60)
turtle.right(90)
turtle.circle(200, 60)

turtle.done()


**效果图**


![](https://imgconvert.csdnimg.cn/aHR0cHM6Ly9tbWJpei5xcGljLmNuL21tYml6X2dpZi9jYkNMZ2ZKWmlicHF4d213YlhlQXNsaWNBMWljaWJoaWJubDF1ajlSWWNIeUthanVpYU1Wc0JZVHBvdDVDVk93dGUwSHZUbEhNZHVpY2hDc0V0UmlhQW9JNjBBZERnLzY0MA?x-oss-process=image/format,png)
#### 2、用turtle库画爱心加文字



import turtle
import random

def love(x, y): # 在(x,y)处画爱心lalala
lv = turtle.Turtle()
lv.hideturtle()
lv.up()
lv.goto(x, y) # 定位到(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)
# 开始画爱心lalala
lv.down()
lv.begin_fill()
lv.left(140)
lv.forward(22)
curvemove()
lv.left(120)
curvemove()
lv.forward(22)
lv.write("YZ", 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(1000)
t.left(90)
t.up()
t.backward(200)
t.down()
t.color(“brown”)
t.pensize(32)
t.forward(60)
tree(100, t)
myWin.exitonclick()


**效果图**


![](https://imgconvert.csdnimg.cn/aHR0cHM6Ly9tbWJpei5xcGljLmNuL21tYml6X2dpZi9jYkNMZ2ZKWmlicHF4d213YlhlQXNsaWNBMWljaWJoaWJubDF1UDdaM2ljdjByNDdYeU1QdUFwT1BLQlhyNjdxM2p1SGphOERiNEpWTDhaUFhrQjF3MDhQVzZvdy82NDA?x-oss-process=image/format,png)
**三、高阶版**


1、星空下的告白



“”"
代码用途:表白
作者:开源Linux
“”"

def bgpic(self, picname=None):
“”"Set background image or return name of current backgroundimage.

    Optional argument:
    picname -- a string, name of a gif-file or "nopic".

    If picname is a filename, set the corresponding image as background.
    If picname is "nopic", delete backgroundimage, if present.
    If picname is None, return the filename of the current backgroundimage.

    Example (for a TurtleScreen instance named screen):
    >>> screen.bgpic()
    'nopic'
    >>> screen.bgpic("landscape.gif")
    >>> screen.bgpic()
    'landscape.gif'
    """
    if picname is None:
        return self._bgpicname
    if picname not in self._bgpics:
        self._bgpics[picname] = self._image(picname)
    self._setbgpic(self._bgpic, self._bgpics[picname])
    self._bgpicname = picname

coding: utf-8

import pygame
import os
import sys
from pygame.locals import *
os.chdir(‘F:/微信公众号/Python/29.加载音乐’)
os.getcwd()
pygame.init()
pygame.mixer.init()
pygame.mixer.music.load(“告白.mp3”)
#pygame.mixer.music.set_volume(0.4)
pygame.mixer.music.play()
bg_size = width, height = 300, 200
bg_rgb = (255, 255, 255)
screen1 = pygame.display.set_mode(bg_size)
pygame.display.set_caption(“告白音乐”)
clock = pygame.time.Clock()
play_image = pygame.image.load(“开始和暂停按钮2.png”).convert_alpha()
pause_image = pygame.image.load(“开始和暂停按钮2.png”).convert_alpha()
pause_rect = pause_image.get_rect()
print(pause_rect.width,pause_rect.height)
pause_rect.left, pause_rect.top = (width - pause_rect.width) // 2, (height - pause_rect.height) // 2
from turtle import *
from random import random,randint
os.chdir(‘F:/微信公众号/Python/0.已发表’)
screen = Screen()
width ,height = 900,700
screen.setup(width,height)
screen.title(“告白”)
screen.bgcolor(“black”)
screen.bgpic(r’./星空下互相告白的两个人2.gif’)
screen.mode(“logo”)
screen.delay(0)
printer = Turtle()
printer.hideturtle()
printer.penup()
printer.color(‘red’)
printer.goto(-100,-350)
printer.write(“In the whole universe\n\n”,move = True, align=“left”, font=(“Italic”, 30, “bold”))
printer.goto(-50,-400)
printer.write(“YZ I only love you!\n\n”,move = True, align=“left”, font=(“Italic”, 30, “bold”))
t = Turtle(visible = False,shape=‘circle’)
t.pencolor(“white”)
t.fillcolor(“white”)
t.penup()
t.setheading(-90)
t.goto(width/2,randint(-height/2,height/2))
stars = []
for i in range(300):
star = t.clone()
s =random()/3
if s>0.01 and s<0.03:
star.pencolor(“black”)
star.fillcolor(“black”)
elif s>0.03 and s<0.04:
star.pencolor(“lightcoral”)
star.fillcolor(“lightcoral”)
elif s>0.05 and s<0.1:
star.pencolor(“green”)
star.fillcolor(“green”)
elif s>0.15 and s<0.16:
star.pencolor(“yellow”)
star.fillcolor(“yellow”)
elif s>0.19 and s<0.2:
star.pencolor(“red”)
star.fillcolor(“red”)
elif s>0.21 and s<0.22:
star.pencolor(“purple”)
star.fillcolor(“purple”)
elif s>0.29 and s<0.3:
star.pencolor(“darkorange”)
star.fillcolor(“darkorange”)
elif s>0.31 and s<0.32:
star.pencolor(“red”)
star.fillcolor(“yellow”)
elif s>0.32 and s<0.33:
star.pencolor(“yellow”)
star.fillcolor(“white”)
star.shapesize(s,s)
star.speed(int(s*30))
star.setx(width/2 + randint(1,width))
star.sety( randint(-height/2,height/2))
#star.showturtle()
stars.append(star)
i = 0
pause = False
while True:
i += 0
for star in stars:

    star.setx(star.xcor() - 3 * star.speed())
    if star.xcor()<-width/2:
        star.hideturtle()
        star.setx(width/2 + randint(1,width))
        star.sety( randint(-height/2,height/2))
        star.showturtle()
if i>= 100:
    break

# 查找队列事件
for event in pygame.event.get():
    # 查找点击关闭窗口事件
    if event.type == QUIT:
        sys.exit
    # 查找鼠标左右击事件
    if event.type == MOUSEBUTTONDOWN:
        if event.button == 1:
            pause = not pause
        if event.button == 3:
            pause = not pause

    if event.type == KEYDOWN:
        if event.key == K_SPACE:
            pause = not pause
screen1.fill(bg_rgb)
if pause:
    pygame.mixer.music.pause()
    screen1.blit(pause_image, pause_rect)
else:
    pygame.mixer.music.unpause()
    screen1.blit(play_image, pause_rect)
pygame.display.flip()
clock.tick(30)

**效果图**


![](https://imgconvert.csdnimg.cn/aHR0cHM6Ly9tbWJpei5xcGljLmNuL21tYml6X2dpZi9jYkNMZ2ZKWmlicHF4d213YlhlQXNsaWNBMWljaWJoaWJubDF1MFo1ZHBwcDFQUldaSWljbGRnUG5aUldncEkzWHRLYTUySTVxZ2h4aklrNEE4Q3dSUEhVd3dRZy82NDA?x-oss-process=image/format,png)
注:如需源代码和照片,请在公众号中回复“**520**”,即可免费获取。


#### 2、照片墙



#!/usr/bin/env python

encoding: utf-8

from PIL import Image
import cv2
import os
os.chdir(r"F:\微信公众号\Python\30.520表白\代码\照片墙\new")
img = cv2.imread(“start.jpg”)
height,width,channels = img.shape
unit_size = 120
y_index = height//unit_size
x_index = width//unit_size
new_img = Image.new(‘RGB’,(width,height),‘#FFFFFF’)
pic_list = []
for item in os.listdir(“small_pictures”):
if item.endswith(“.jpg”) or item.endswith(“.JPG”) :
pic_list.append(item)
total = len(pic_list)
x=0
y=0
for i in range(x_indexy_index):
print(f"目前进度{i}/{x_index
y_index}")
test = Image.open(“small_pictures/” + pic_list[i%total]).resize((unit_size,unit_size), Image.ANTIALIAS)
new_img.paste(test,(xunit_size,yunit_size))
x+=1
if x==x_index:
x=0
y+=1
print(“素材图合成完毕!”)
new_img.save(“out.jpg”,quality=100)
src1 = cv2.imread(“start.jpg”)

先自我介绍一下,小编浙江大学毕业,去过华为、字节跳动等大厂,目前在阿里

深知大多数程序员,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

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

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

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

需要这份系统化的资料的朋友,可以点击这里获取!

,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。**
[外链图片转存中…(img-MxL7pKMN-1715698649478)]
[外链图片转存中…(img-R9B6KcqF-1715698649478)]
[外链图片转存中…(img-YS7xzbc4-1715698649479)]
[外链图片转存中…(img-NwfMuBLy-1715698649479)]
[外链图片转存中…(img-IjHGaDtv-1715698649479)]

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

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

需要这份系统化的资料的朋友,可以点击这里获取!

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值