首页
壁纸
放映厅
留言板
更多
直播
推荐
百度一下
腾讯视频
Search
1
2026新年快乐Python代码
18 阅读
2
酷狗音乐歌手写真api分享
9 阅读
3
欢迎使用 Typecho
7 阅读
4
用百度统计为你的博客赋能
7 阅读
5
Flink快速入门
7 阅读
前端
鸿蒙开发
后端
软件测试
python
人工智能
UI设计
软件分享
教程
网络安全
大数据
登录
Search
标签搜索
python
大数据
scala
前端
爬虫
Spark
运维
百度
数据采集
flink
跨年代码
API接口
windows
HTML
javascript
端口占用
django
服务器
命令
网络
小雷Debug
累计撰写
9
篇文章
累计收到
3
条评论
首页
栏目
前端
鸿蒙开发
后端
软件测试
python
人工智能
UI设计
软件分享
教程
网络安全
大数据
页面
壁纸
放映厅
留言板
直播
推荐
百度一下
腾讯视频
搜索到
3
篇与
python
的结果
2026-01-01
2026新年快乐Python代码
今天是2026的第一天,新的一年,祝我们得偿所愿,平安喜乐,烟火漫漫,开心满满,八方来财,岁岁平安,万事尽可期待,一路好运常在,我们都要,越来越好!新年快乐~~下面是用Python编写的新年快乐代码:import pygame as pg import random as ra import math pg.init() pg.display.set_caption("🎇") winScreen = pg.display.Info() screenWidth = winScreen.current_w screenHeight = winScreen.current_h vector = pg.math.Vector2 trail_colors = [(45, 45, 45), (60, 60, 60), (75, 75, 75), (125, 125, 125), (150, 150, 150)] # 烟花类 class Firework: def __init__(self): # 随机生成颜色 self.colour = (ra.randint(0, 255), ra.randint(0, 255), ra.randint(0, 255)) # 随机生成三种颜色 self.colours = ( (ra.randint(0, 255), ra.randint(0, 255), ra.randint(0, 255)), (ra.randint(0, 255), ra.randint(0, 255), ra.randint(0, 255)), (ra.randint(0, 255), ra.randint(0, 255), ra.randint(0, 255)) ) # 生成一个表示发射出的火花的粒子对象 self.firework = Particle(ra.randint(0,screenWidth), screenHeight, True, self.colour) # 初始化爆炸状态为 False self.exploded = False self.particles = [] # 爆炸产生的粒子数量范围 self.min_max_particles = vector(666, 999) def update(self, win): g = vector(0, ra.uniform(0.15, 0.4)) if not self.exploded: # 给发射出的火花施加重力 self.firework.apply_force(g) self.firework.move() for tf in self.firework.trails: tf.show(win) self.show(win) if self.firework.vel.y >= 0: self.exploded = True self.explode() else: for particle in self.particles: # 给爆炸产生的粒子施加随机力 particle.apply_force(vector(g.x + ra.uniform(-1, 1) / 20, g.y / 2 + (ra.randint(1, 8) / 100))) particle.move() for t in particle.trails: t.show(win) particle.show(win) def explode(self): amount = ra.randint(int(self.min_max_particles.x), int(self.min_max_particles.y)) for i in range(amount): # 在爆炸位置生成粒子对象并添加到粒子列表中 self.particles.append(Particle(self.firework.pos.x, self.firework.pos.y, False, self.colours)) def show(self, win): # 绘制发射出的火花 pg.draw.circle(win, self.colour, (int(self.firework.pos.x), int(self.firework.pos.y)), self.firework.size) def remove(self): if self.exploded: for p in self.particles: if p.remove is True: self.particles.remove(p) if len(self.particles) == 0: return True else: return False # 粒子类 class Particle: def __init__(self, x, y, firework, colour): self.firework = firework self.pos = vector(x, y) self.origin = vector(x, y) self.radius = 25 self.remove = False self.explosion_radius = ra.randint(15, 25) self.life = 0 self.acc = vector(0, 0) self.trails = [] self.prev_posx = [-10] * 10 self.prev_posy = [-10] * 10 if self.firework: self.vel = vector(0, -ra.randint(17, 20)) self.size = 5 self.colour = colour for i in range(5): self.trails.append(Trail(i, self.size, True)) else: self.vel = vector(ra.uniform(-1, 1), ra.uniform(-1, 1)) self.vel.x *= ra.randint(7, self.explosion_radius + 2) self.vel.y *= ra.randint(7, self.explosion_radius + 2) self.size = ra.randint(2, 4) self.colour = ra.choice(colour) for i in range(5): self.trails.append(Trail(i, self.size, False)) def apply_force(self, force): # 施加力 self.acc += force def move(self): if not self.firework: # 爆炸产生的粒子减速 self.vel.x *= 0.8 self.vel.y *= 0.8 self.vel += self.acc self.pos += self.vel self.acc *= 0 if self.life == 0 and not self.firework: # 判断是否超出爆炸半径 distance = math.sqrt((self.pos.x - self.origin.x) ** 2 + (self.pos.y - self.origin.y) ** 2) if distance > self.explosion_radius: self.remove = True self.decay() self.trail_update() self.life += 1 def show(self, win): # 绘制粒子 pg.draw.circle(win, (self.colour[0], self.colour[1], self.colour[2], 0), (int(self.pos.x), int(self.pos.y)), self.size) def decay(self): if 50 > self.life > 10: ran = ra.randint(0, 30) if ran == 0: self.remove = True elif self.life > 50: ran = ra.randint(0, 5) if ran == 0: self.remove = True def trail_update(self): self.prev_posx.pop() self.prev_posx.insert(0, int(self.pos.x)) self.prev_posy.pop() self.prev_posy.insert(0, int(self.pos.y)) for n, t in enumerate(self.trails): if t.dynamic: t.get_pos(self.prev_posx[n + 1], self.prev_posy[n + 1]) else: t.get_pos(self.prev_posx[n + 5], self.prev_posy[n + 5]) # 痕迹类 class Trail: def __init__(self, n, size, dynamic): self.pos_in_line = n self.pos = vector(-10, -10) self.dynamic = dynamic if self.dynamic: self.colour = trail_colors[n] self.size = int(size - n / 2) else: self.colour = (255, 255, 200) self.size = size - 2 if self.size < 0: self.size = 0 def get_pos(self, x, y): self.pos = vector(x, y) def show(self, win): # 绘制痕迹 pg.draw.circle(win, self.colour, (int(self.pos.x), int(self.pos.y)), self.size) def update(win, fireworks): for fw in fireworks: fw.update(win) if fw.remove(): fireworks.remove(fw) pg.display.update() def fire(): screen = pg.display.set_mode((screenWidth, screenHeight - 66)) clock = pg.time.Clock() fireworks = [Firework() for i in range(2)] running = True # 加载字体 font = pg.font.SysFont("comicsansms", 99) # 渲染文本 text = "再见2025,你好2026" # 设置字体为支持中文的字体 font = pg.font.Font("C:/Windows/Fonts/msyh.ttc", 99) # 微软雅黑字体路径 # font = pg.font.SysFont("SimHei", 99) # 黑体 text_color = (255, 190, 200) # 字体颜色 rendered_text = font.render(text, True, text_color) rendered_text = font.render(text, True, text_color) while running: clock.tick(99) for event in pg.event.get(): if event.type == pg.QUIT: running = False # 计算文本位置 text_width = rendered_text.get_width() text_height = rendered_text.get_height() text_x = (screenWidth - text_width) // 2 text_y = (screenHeight - text_height) // 2 - 99 screen.fill((20, 20, 30)) # 绘制文本 screen.blit(rendered_text, (text_x, text_y)) if ra.randint(0, 10) == 1: fireworks.append(Firework()) update(screen, fireworks) pg.quit() quit() if __name__ == "__main__": fire()注意:在运行该代码时,请确保你已安装pygame三方库如果没有安装,请使用如下命令进行安装:pip install pygame废话不多说,看效果图:
2026年01月01日
18 阅读
0 评论
2 点赞
2025-11-05
酷狗音乐歌手写真api分享
最近闲着无聊,发现了酷狗的一个开放接口😘,通过该接口用户可以获取酷狗歌手写真😍https://openapicdnretry.kugou.com/kmr/v1/author/extend?fields_pack=allimages&authorimg_type=4,5&entity_id= 接下来我将对该接口进行使用讲解:请求方式GET参数列表authorimg_type4,5 获取手机端歌手写真2,3 获取PC端歌手写真entity_id歌手id示例:https://openapicdnretry.kugou.com/kmr/v1/author/extend?fields_pack=allimages&authorimg_type=4,5&entity_id=3520返回数据:{ "error_code": 0, "msg": "", "data": [ { "__status": 1, "base": { "author_id": 3520, "author_name": "周杰伦", "is_publish": 1, "language": "华语", "avatar": "http://singerimg.kugou.com/uploadpic/softhead/{size}/20230510/20230510173043311.jpg", "identity": 15, "type": 1, "country": "中国", "birthday": "1979-01-18" }, "imgs": [ { "id": 551578, "file": "http://imge.kugou.com/v2/mobile_portrait/2cfe9ac7f88d968ed09a8e422b493388.jpg", "hash": "2cfe9ac7f88d968ed09a8e422b493388", "publish_time": "2015-01-01", "source": 0, "type": 4 }, { "id": 4999620, "file": "http://imge.kugou.com/v2/mobile_portrait/8c0247d610c292b975e713df5a9a2217.jpg", "hash": "8c0247d610c292b975e713df5a9a2217", "publish_time": "2012-01-01", "source": 0, "type": 4 }, ... ] } ], "status": 1 }示例图像:趁着酷小狗🐶还没发现,快去用起来吧😍
2025年11月05日
9 阅读
0 评论
0 点赞
2022-12-25
关于python-Django项目报错 Error: [WinError 10013] 以一种访问权限不允许的方式做了一个访问套接字的尝试
请看下图他竟然提示我 以一种访问权限不允许的方式做了一个访问套接字的尝试。那为什么会出现这个问题呢?出现这种错误有两种的原因:1.使用的端口号被占用解决办法:查看端口是否被占用,打开cmd,输入netstat -ano即可查看端口是否被占用,如果被占用,则修改端口或者结束占指定端口的程序。很明显,我的80端口已被PID为19380的程序占用,然后我打开了任务管理器,发现是酷狗占了我的80端口 此时,就可以对症下药了。我选择了切换端口号。OK,问题解决!2.程序权限不够解决办法:如果是在VScode中编程,则让VScode以管理员的方式启动,则不会报Socket错误,生成的应用程序也需要以管理员启动。希望我的这篇博客能够帮助到一部分人吧,再见!
2022年12月25日
3 阅读
0 评论
0 点赞