猫史档案馆


【Python作品分享】[文字游戏]喵【作品秀】

用户:小麦做的面包小麦做的面包查看:6 回复:6 评论:6 创建时间:2022-07-18T09:17:53


【作品展示】

center_image

 

【作品介绍】

注意!!!本程序不需手动下载任何图片,程序会自动用爬虫下载

 

【作品源代码】

import random,math,requests
from time import sleep
from matplotlib import pyplot as plt
from PIL import Image
from contextlib import closing

def say(txt):
    return input('???:'+txt)


def line(l=1):
    for i in range(l):
        print("\033[A"+' '*103+"\033[A")


def q(txt):
    user = say(txt+' >>>')
    if user == '1':
        return 1
    elif user == '2':
        say('好吧,拜拜')
    else:
        return q(txt)


def main():
    say('你好(按回车键继续)')
    say('我要在你的电脑里放一个喵')
    say('但是你要先下载一下喵')
    if q('行吗? 1:行 2:不行'):
        download()


def download():
    say('好的')
    say('开始下载')
    print('下载喵中')
    i = 0
    while i < 100:
        print(str(round(i, 2))+'%')
        sleep(0.02)
        i += random.random()
        line()
    line()
    print('喵下载成功')
    print('100.00%')
    sleep(1)
    say('哈'*30)
    say('现在我能让你的电脑爆炸了')
    say('现在我会让喵开始20秒计时')
    say('但是这个喵的时间有亿点点不准')
    if q('开始计时吗? 1:开始 2:不开始'):
        time()


def time():
    t = 20
    say("喵开始计时,20秒后爆炸")
    while t > 0:
        print('剩余时间:', t)
        sleep(random.random())
        line()
        if random.random() > 0.1:
            t -= 1
        else:
            t += 1
    print('剩余时间:', t)
    sleep(1)
    say('哈'*30)
    say('时间到了')
    say('现在只需要加载一会就能爆炸啦')
    if q('你要加载吗? 1:好啊 2:不要'):
        load()


def load():
    say('开始加载')
    print('加载中')
    i = 0
    while i < 100:
        print(str(round(i, 2))+'%')
        sleep(0.05)
        i += random.random()
        line()
    print('99.', end='', flush=True)
    for i in range(50):
        print('9', end='', flush=True)
        sleep(i/100)
    print('%')
    say('为什么加载不了?')
    say('我的网好像有点卡...')
    say('我连接不上亻')
    say('为什么我不能完整地说讠')
    say('发生亻')
    for i in range(3):
        print('???:网络连接中', end='', flush=True)
        sleep(0.4)
        for j in range(6):
            print('.', end='', flush=True)
            sleep(0.4)
        print('')
        line()
    say('网络已连接')
    line(8)
    print('喵加载成功')
    print('100%')
    say('喵要爆炸了!')
    url = 'https://kn-cdn.codemao.cn/wood/image/H1DSaobd2t.jpg'
    img = requests.get(url, stream=True)
    with closing(requests.get(url, stream=True)) as response:
        with open('boom.jpg', 'wb') as file:
            for data in response.iter_content(128):
                file.write(data)
    img = Image.open('boom.jpg')
    plt.imshow(img)
    plt.show()
    print('张三:我张三做好事不留名!')

main()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
小麦做的面包小麦做的面包

while 1:
    print('d')

点赞0


评论


小麦做的面包小麦做的面包

没人?

 

点赞0


评论


小麦做的面包小麦做的面包

别沉啊

点赞0


评论


玛卡巴卡126玛卡巴卡126

张三.....

点赞0


评论


adofaiadofai

张三?

点赞0


评论


小麦做的面包小麦做的面包

 

点赞0


评论