用python写的新年快乐的代码,python节日祝福源代码

这篇具有很好参考价值的文章主要介绍了用python写的新年快乐的代码,python节日祝福源代码。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

这篇文章主要介绍了用python写的新年快乐的代码,具有一定借鉴价值,需要的朋友可以参考下。希望大家阅读完这篇文章后大有收获,下面让小编带着大家一起了解一下。

python新年快乐代码,pygame,python,开发语言,servlet

import os

import time

import random

import pygame

import colorama

‘‘‘一些变量‘‘‘

BGMPATH = ‘bgm.mp3‘

colorama.init(convert=True)

STARS = [2, 4, 8, 10, 14, 20, 26, 28, 40, 44, 52, 60, 64, 76]

HEARTS = [13, 27, 41, 55, 69, 77]

FLOWERS = [7, 15, 23, 31, 39, 46]

RED = colorama.Fore.RED + colorama.Style.BRIGHT

CYAN = colorama.Fore.CYAN + colorama.Style.BRIGHT

GREEN = colorama.Fore.GREEN + colorama.Style.BRIGHT

YELLOW = colorama.Fore.YELLOW + colorama.Style.BRIGHT

MAGENTA = colorama.Fore.MAGENTA + colorama.Style.BRIGHT

‘‘‘程序背景音乐‘‘‘

# def playBGM(bgm_path):

# pygame.mixer.init()

# pygame.mixer.music.load(bgm_path)

# pygame.mixer.music.play(-1)

‘‘‘换行‘‘‘

def nextLine():

time.sleep(0.3)

print()

‘‘‘画心‘‘‘

def drawHeart():

num_spaces = random.randint(8, 80)

print(‘ ‘ * num_spaces, end=‘‘)

for i in range(78):

if i in HEARTS:

nextLine()

print(‘ ‘ * num_spaces, end=‘‘)

elif i in STARS:

print(RED + ‘*‘, end=‘‘)

elif i in [31, 35]:

print(GREEN + ‘2‘, end=‘‘)

elif i in [33, 37]:

print(GREEN + ‘0‘, end=‘‘)

else:

print(‘ ‘, end=‘‘)

‘‘‘显示祝福文字‘‘‘

def showText():

print(‘ ‘ * random.randint(8, 80), end=‘‘)

print(CYAN + "Happy new year!", end=‘‘)

‘‘‘画花‘‘‘

def drawFlower():

num_spaces = random.randint(8, 80)

print(‘ ‘ * num_spaces, end=‘‘)

for i in range(47):

if i in FLOWERS:

nextLine()

print(‘ ‘ * num_spaces, end=‘‘)

elif i in [2, 8, 12, 18]:

print(MAGENTA + ‘{‘, end=‘‘)

elif i in [3, 9, 13, 19]:

print(MAGENTA + ‘_‘, end=‘‘)

elif i in [4, 10, 14, 20]:

print(MAGENTA + ‘}‘, end=‘‘)

elif i in [27, 35, 43]:

print(GREEN + ‘|‘, end=‘‘)

elif i in [34, 44]:

print(GREEN + ‘~‘, end=‘‘)

elif i == 11:

print(YELLOW + ‘o‘, end=‘‘)

else:

print(‘ ‘, end=‘‘)

‘‘‘清屏‘‘‘

def clearScreen():

try:

os.system(‘cls‘)

except:

os.system(‘clear‘)

‘‘‘主程序‘‘‘

def main():

# playBGM(BGMPATH)

clearScreen()

while True:

drawHeart()

nextLine()

showText()

nextLine()

nextLine()

drawFlower()

print()

if __name__ == ‘__main__‘:

main()

原文:https://www.cnblogs.com/walkwaters/p/12128016.html文章来源地址https://www.toymoban.com/news/detail-771243.html

import os

import time

import random

import pygame

import colorama

‘‘‘一些变量‘‘‘

BGMPATH = ‘bgm.mp3‘

colorama.init(convert=True)

STARS = [2, 4, 8, 10, 14, 20, 26, 28, 40, 44, 52, 60, 64, 76]

HEARTS = [13, 27, 41, 55, 69, 77]

FLOWERS = [7, 15, 23, 31, 39, 46]

RED = colorama.Fore.RED + colorama.Style.BRIGHT

CYAN = colorama.Fore.CYAN + colorama.Style.BRIGHT

GREEN = colorama.Fore.GREEN + colorama.Style.BRIGHT

YELLOW = colorama.Fore.YELLOW + colorama.Style.BRIGHT

MAGENTA = colorama.Fore.MAGENTA + colorama.Style.BRIGHT

‘‘‘程序背景音乐‘‘‘

# def playBGM(bgm_path):

# pygame.mixer.init()

# pygame.mixer.music.load(bgm_path)

# pygame.mixer.music.play(-1)

‘‘‘换行‘‘‘

def nextLine():

time.sleep(0.3)

print()

‘‘‘画心‘‘‘

def drawHeart():

num_spaces = random.randint(8, 80)

print(‘ ‘ * num_spaces, end=‘‘)

for i in range(78):

if i in HEARTS:

nextLine()

print(‘ ‘ * num_spaces, end=‘‘)

elif i in STARS:

print(RED + ‘*‘, end=‘‘)

elif i in [31, 35]:

print(GREEN + ‘2‘, end=‘‘)

elif i in [33, 37]:

print(GREEN + ‘0‘, end=‘‘)

else:

print(‘ ‘, end=‘‘)

‘‘‘显示祝福文字‘‘‘

def showText():

print(‘ ‘ * random.randint(8, 80), end=‘‘)

print(CYAN + "Happy new year!", end=‘‘)

‘‘‘画花‘‘‘

def drawFlower():

num_spaces = random.randint(8, 80)

print(‘ ‘ * num_spaces, end=‘‘)

for i in range(47):

if i in FLOWERS:

nextLine()

print(‘ ‘ * num_spaces, end=‘‘)

elif i in [2, 8, 12, 18]:

print(MAGENTA + ‘{‘, end=‘‘)

elif i in [3, 9, 13, 19]:

print(MAGENTA + ‘_‘, end=‘‘)

elif i in [4, 10, 14, 20]:

print(MAGENTA + ‘}‘, end=‘‘)

elif i in [27, 35, 43]:

print(GREEN + ‘|‘, end=‘‘)

elif i in [34, 44]:

print(GREEN + ‘~‘, end=‘‘)

elif i == 11:

print(YELLOW + ‘o‘, end=‘‘)

else:

print(‘ ‘, end=‘‘)

‘‘‘清屏‘‘‘

def clearScreen():

try:

os.system(‘cls‘)

except:

os.system(‘clear‘)

‘‘‘主程序‘‘‘

def main():

# playBGM(BGMPATH)

clearScreen()

while True:

drawHeart()

nextLine()

showText()

nextLine()

nextLine()

drawFlower()

print()

if __name__ == ‘__main__‘:

main()

原文:https://www.cnblogs.com/walkwaters/p/12128016.html

到了这里,关于用python写的新年快乐的代码,python节日祝福源代码的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 用python给朋友做生日快乐祝福

    主要使用python的turtle库进行绘制 speed控制画笔的速度,大小在(0, 10),0是最快的 代码如下 这里是运行效果图 主要使用pygame实现烟花效果 代码如下 其中这个是烟花的背景图,“happy birthday”是图片的名字,这个图片需要和.py文件放在一个文件夹里面 运行结果截图如下 导

    2024年02月13日
    浏览(36)
  • C语言系列之炫酷新年烟花秀(带新年祝福)

    新年即将到来,由于全国各地的政策不一样,也许有的地方会禁止燃放烟花,那么就来一款别开生面的电子烟花,让大家感受一下过年的氛围吧。 代码呈上: 小伙伴们快去试试吧!!

    2024年02月03日
    浏览(29)
  • 以AI作画,祝她节日快乐

    近期,ChatGPT的爆火,引起了大众对于AIGC(AI Generate Content AI生成内容)的广泛关注。作为技术领域的又一热点话题——AIGC距离大众使用似乎还存在一定距离? 等风来不如追风去。随着第113个“三·八”国际妇女节于春日中悄然来临,OpenVINO™ 特推出“以AI作画,祝她节日快乐

    2024年02月11日
    浏览(38)
  • BUUCTF中的“新年快乐”

    0x00 前言 今天看了一下日期,距过年还有28天,正好今天做的题目也叫新年快乐,就提前给大家拜个早年,祝大家早年幸福。 0x01 正文 虽然是新年快乐的题,但是打开是一点儿都不快乐,它让我输入flag。 既然这样的话,那只好PE一下打开看看啰。   于是,遇见了做题以来的

    2024年02月08日
    浏览(28)
  • Go语言实现新年快乐的效果

    在 Go 语言中,你可以使用 fmt 包来实现新年快乐的效果。以下是一个简单的例子: 在这个例子中,我使用 ANSI 转义码来设置输出的颜色。 \\033[31m 表示红色, \\033[32m 表示绿色, \\033[33m 表示黄色, \\033[36m 表示青色, \\033[35m 表示紫色, \\033[0m 用于重置颜色。 请注意,在不同的终

    2024年01月23日
    浏览(29)
  • 新年快乐—数睿通2.0数据中台全新功能模块发布

    离上次发文已经有接近三个月了,这三个月主要在开发数睿通的数据生产模块,同时优化了一下数据集成,目前已经基本开发完毕了,集成了 Flink,Hadoop,可以在线开发 FlinkSql 作业任务,同时支持 Sql 任务开发,使平台初步具备了拉数,造数的能力,正值新年,在这里给大家

    2024年02月02日
    浏览(35)
  • 新年快乐!学习Java第84天,Maven工程继承和聚合关系

    1. Maven工程继承关系 继承概念 Maven 继承是指在 Maven 的项目中,让一个项目从另一个项目中继承配置信息的机制。继承可以让我们在多个项目中共享同一配置信息,简化项目的管理和维护工作。 继承作用 在父工程中统一管理项目中的依赖信息。 它的背景是: 对一个比较大型

    2024年02月03日
    浏览(29)
  • 以AI作画,祝她节日快乐;简单三步,OpenVINO™ 助你轻松体验AIGC

    近期,ChatGPT的爆火,引起了大众对于AIGC(AI Generate Content AI生成内容)的广泛关注。作为技术领域的又一热点话题——AIGC距离大众使用似乎还存在一定距离? 等风来不如追风去。随着第113个“三·八”国际妇女节于春日中悄然来临,OpenVINO™ 特推出“以AI作画,祝她节日快乐

    2024年02月08日
    浏览(30)
  • 母亲节快到了,祝所有母亲节日快乐!Happy Mother‘s Day

    《游子吟》唐·孟郊 慈母手中线,游子身上衣。 临行密密缝,意恐迟迟归。 谁言寸草心,报得三春晖。 My kind mother has a needle and thread in her hand,Making new clothes for her son who is to travel far away. She is busy sewing closely before my leaving,Worried that I cannot come back for a long time. Who says that the h

    2024年02月04日
    浏览(29)
  • Python新年烟花代码

    Pygame 绘制烟花的基本原理 1,发射阶段:在这一阶段烟花的形状是线性向上,通过设定一组大小不同、颜色不同的点来模拟“向上发射” 的运动运动,运动过程中 5个点被赋予不同大小的加速度,随着时间推移,后面的点会赶上前面的点,最终所有点会汇聚在一起,处于 绽放

    2024年02月03日
    浏览(43)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包