猫史档案馆


【Python作品分享】生活必备【作品秀】

用户:STARRYWFSTARRYWF查看:0 回复:1 评论:0 创建时间:2022-06-18T20:31:44


【作品展示】

center_image

 

【作品介绍】

代码太多,如果想获取代码可以私聊

 

【作品源代码】

import ybc_box as box
import ybc_china as china
import ybc_weather as w
import ybc_news as n
import ybc_carbrand as cb
import ybc_pic_search as search
import os
import ybc_speech as speech
import ybc_browser as bs
import random
import ybc_pminfo as pminfo
import ybc_trans as trans

while True:
    ans = box.buttonbox('请选择操作:' + '\n' + '更多功能开发中,敬请期待......', [ '天气预报', '看看电脑眼中的你', '今日头条', '汽车品牌大全', '打开网址小助手', 'pm2.5实时检测', '简单的计算器', '翻译小程序', '所有'])
    if ans == None:
        break
    elif ans == '天气预报':
        cits = china.all_cities()
        c = box.enterbox('请输入城市名称')
        if c in cits:
            op = box.buttonbox('请选择查询类型', ['今日天气', '一周天气'])
            if op == '今日天气':
                res = w.today(c)
                box.msgbox(res)
            elif op == '一周天气':
                ans = w.week(c)
                box.tablebox('一周天气', ans)
        else:
            box.msgbox('输入的城市查询不到哦~')

    elif ans == '看看电脑眼中的你':
        box.msgbox('让我们来看看,电脑眼中的你是怎样的吧~')
        lst = ['身高', '智商', '性格', '五官', '身材', '头发', '视力']
        words = '棒萌高衰胖秃牛菜'
        name = box.enterbox('请输入你的姓名')
        for i in lst:
            while True:
                w = random.choice(words)
                res = speech.speak(name + '的' + i + '是' + w + '的')
                if res == None:
                    break

    elif ans == '今日头条':
        ps = n.channels()
        op = box.buttonbox('请选择', ps)
        ns = n.news(op)
        #box.msgbox(ns[0][0] + ns[0][1],ns[0][2])
        for i in ns:
            res = box.msgbox(i[0] + '\n' + i[1], i[2])
            if res == None:
                break

    elif ans == '汽车品牌大全':
        box.msgbox('汽车品牌大全~')
        res = cb.brands()
        choice = box.buttonbox('汽车类型:', res)
        if choice != None:
            num = box.enterbox('输入下载数量:(1~20)')
            num = int(num)
            if num >= 1 and num < 20 and num != None:
                search.car(choice, num)
                flies = os.listdir(choice)
                for filename in flies:
                    filename = choice + '/' + filename
                    box.msgbox('展示图片', filename)
                box.msgbox('图片下载完成~')
            else:
                box.msgbox('输入的下载数量错误~')
        else:
            box.msgbox('谢谢使用')

    elif ans == '打开网址小助手':
        dic = {
            '百度': 'www.喵',
            '猿编程': 'www.ybccode.com',
            '微博': 'www.weibo.com',
            'QQ音乐': 'y.qq.com',
            '爱奇艺': 'www.iqiyi.com',
            '四三九九小游戏': 'www.4399.com',
            '哔哩哔哩': 'www.bilibili.com',
            '壮猿表情包': 'show.ybccode.com/emojis1'
        }
        box.msgbox('语音小助手,用语音控制电脑打开网页吧~')
        voice = speech.record('1.mp3')
        if voice == None:
            box.msgbox('再见')
            break
        key = speech.voice2text(voice)
        if key in dic:
            bs.open(dic[key])
        else:
            box.msgbox('查询不到网址' + key)
            url = box.enterbox('请添加新网址')
            if url == '' or url == None:
                box.msgbox('您没输入内容哦~')
            else:
                dic[key] = url
                print(dic)

    elif ans == 'pm2.5实时检测':
        cits = china.all_cities()
        c = box.enterbox('输入城市:')
        if c in cits:
            info = pminfo.pm25(c)
            pm1 = '【城市】:' + info['city'] + '\n'
            pm2 = '【PM2.5值】:' + str(info['pm25']) + '\n'
            pm3 = '【空气质量】:' + info['quality'] + '\n'
            pm4 = '【影响】:' + info['affect'] + '\n'
            pm5 = '【建议】:' + info['advise']
            img = '【pm2.5浓度等级】:' + info['level'] + '\n'
            rews = pm1 + pm2 + pm3 + img + pm4 + pm5
            box.msgbox(rews)
            op = box.buttonbox('是否查看具体信息?', ['是', '否'])
            if op == '是':
                position = info['position']
                for pos in position:
                    pp = box.msgbox(pos['posname'] + ':' + str(pos['pm25']))
                    if pp == None:
                        break
            aps = box.buttonbox('是否继续?', ['是', '否'])
            if aps == '是':
                continue
            elif aps == None:
                break
            else:
                break
        elif c == None:
            break
        else:
            box.msgbox('输入的城市查询不到哦!')

    elif ans == '简单的计算器':
        box.msgbox('简单的计算器~')
        op = box.buttonbox('请选择功能', ['加法', '减法', '乘法', '除法'])
        if op == '加法':
            num1 = box.enterbox('请输入第一个数字')
            num2 = box.enterbox('请输入第二个数字')
            box.msgbox(int(num1) + int(num2))
        elif op == '减法':
            num1 = box.enterbox('请输入第一个数字')
            num2 = box.enterbox('请输入第二个数字')
            box.msgbox(int(num1) - int(num2))
        elif op == '乘法':
            num1 = box.enterbox('请输入第一个数字')
            num2 = box.enterbox('请输入第二个数字')
            box.msgbox(int(num1) * int(num2))
        elif op == '除法':
            num1 = box.enterbox('请输入第一个数字')
            num2 = box.enterbox('请输入第二个数字')
            box.msgbox(int(num1) / int(num2))
        elif op == None:
            break
    elif ans == '翻译小程序':
        op = box.buttonbox('请选择你要完成的操作', ['英译中', '中译英', '退出'])
        if op == '退出' or op == None:
            break
        elif op == '英译中':
            words = box.enterbox('输入翻译内容')
            if words == None:
                continue
            res = trans.en2zh(words)
            box.msgbox(res)
        elif op == '中译英':
            words = box.enterbox('输入翻译内容')
            if words == None:
                continue
            res = trans.zh2en(words)
            box.msgbox(res)

    elif ans == '所有':
        box.msgbox('天气预报小程序~')
        cits = china.all_cities()
        c = box.enterbox('请输入城市名称')
        if c in cits:
            op = box.buttonbox('请选择查询类型', ['今日天气', '一周天气'])
            if op == '今日天气':
                res = w.today(c)
                box.msgbox(res)
            elif op == '一周天气':
                ans = w.week(c)
                box.tablebox('一周天气', ans)
        else:
            box.msgbox('输入的城市查询不到哦~')

        box.msgbox('让我们来看看,电脑眼中的你是怎样的吧~')
        lst = ['身高', '智商', '性格', '五官', '身材', '头发', '视力']
        words = '棒萌高衰胖秃牛菜'
        name = box.enterbox('请输入你的姓名')
        for i in lst:
            while True:
                w = random.choice(words)
                res = speech.speak(name + '的' + i + '是' + w + '的')
                if res == None:
                    break

        box.msgbox('今日头条小程序~')
        ps = n.channels()
        op = box.buttonbox('请选择', ps)
        ns = n.news(op)
        #box.msgbox(ns[0][0] + ns[0][1],ns[0][2])
        for i in ns:
            res = box.msgbox(i[0] + '\n' + i[1], i[2])
            if res == None:
                break

        box.msgbox('汽车品牌大全~')
        res = cb.brands()
        choice = box.buttonbox('汽车类型:', res)
        if choice != None:
            num = box.enterbox('输入下载数量:(1~20)')
            num = int(num)
            if num >= 1 and num < 20 and num != None:
                search.car(choice, num)
                flies = os.listdir(choice)
                for filename in flies:
                    filename = choice + '/' + filename
                    box.msgbox('展示图片', filename)
                box.msgbox('图片下载完成~')
            else:
                box.msgbox('输入的下载数量错误~')
        else:
            box.msgbox('谢谢使用')

        box.msgbox('打开网址小助手~')
        dic = {
            '百度': 'www.喵',
            '猿编程': 'www.ybccode.com',
            '微博': 'www.weibo.com',
            'QQ音乐': 'y.qq.com',
            '爱奇艺': 'www.iqiyi.com',
            '4399小游戏': 'www.4399.com',
            '哔哩哔哩': 'www.bilibili.com',
            '壮猿表情包': 'show.ybccode.com/emojis1'
        }
        box.msgbox('语音小助手,用语音控制电脑打开网页吧~')
        voice = speech.record('1.mp3')
        if voice == None:
            box.msgbox('再见')
            break
        key = speech.voice2text(voice)
        if key in dic:
            bs.open(dic[key])
        else:
            box.msgbox('查询不到网址' + key)
            url = box.enterbox('请添加新网址')
            if url == '' or url == None:
                box.msgbox('您没输入内容哦~')
            else:
                dic[key] = url
                print(dic)

        box.msgbox('pm2.5监测小程序~')
        cits = china.all_cities()
        c = box.enterbox('输入城市:')
        if c in cits:
            info = pminfo.pm25(c)
            pm1 = '【城市】:' + info['city'] + '\n'
            pm2 = '【PM2.5值】:' + str(info['pm25']) + '\n'
            pm3 = '【空气质量】:' + info['quality'] + '\n'
            pm4 = '【影响】:' + info['affect'] + '\n'
            pm5 = '【建议】:' + info['advise']
            img = '【pm2.5浓度等级】:' + info['level'] + '\n'
            rews = pm1 + pm2 + pm3 + img + pm4 + pm5
            box.msgbox(rews)
            op = box.buttonbox('是否查看具体信息?', ['是', '否'])
            if op == '是':
                position = info['position']
                for pos in position:
                    pp = box.msgbox(pos['posname'] + ':' + str(pos['pm25']))
                    if pp == None:
                        break
            aps = box.buttonbox('是否继续?', ['是', '否'])
            if aps == '是':
                continue
            elif aps == None:
                break
            else:
                break
        elif c == None:
            break
        else:
            box.msgbox('输入的城市查询不到哦!')

        box.msgbox('简单的计算器~')
        op = box.buttonbox('请选择功能', ['加法', '减法', '乘法', '除法'])
        if op == '加法':
            num1 = box.enterbox('请输入第一个数字')
            num2 = box.enterbox('请输入第二个数字')
            box.msgbox(int(num1) + int(num2))
        elif op == '减法':
            num1 = box.enterbox('请输入第一个数字')
            num2 = box.enterbox('请输入第二个数字')
            box.msgbox(int(num1) - int(num2))
        elif op == '乘法':
            num1 = box.enterbox('请输入第一个数字')
            num2 = box.enterbox('请输入第二个数字')
            box.msgbox(int(num1) * int(num2))
        elif op == '除法':
            num1 = box.enterbox('请输入第一个数字')
            num2 = box.enterbox('请输入第二个数字')
            box.msgbox(int(num1) / int(num2))
        elif op == None:
            break

        box.msgbox('翻译小程序~')
        op = box.buttonbox('请选择你要完成的操作', ['英译中', '中译英', '退出'])
        if op == '退出' or op == None:
            break
        elif op == '英译中':
            words = box.enterbox('输入翻译内容')
            if words == None:
                continue
            res = trans.en2zh(words)
            box.msgbox(res)
        elif op == '中译英':
            words = box.enterbox('输入翻译内容')
            if words == None:
                continue
            res = trans.zh2en(words)
            box.msgbox(res)

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
STARRYWFSTARRYWF

如果你想学python, 建议报名猿辅导的python课程,然后在猿编程里运行这个代码。

如果你已经学过了,那么我还是保持以上建议,这样更好!

作者本人就是猿辅导python优秀毕业生!!!

                                                                                                                                             ——作者原注

点赞0


评论