Python ❀ 使用代码解决今天中午吃什么的重大生存问题

1. 环境安装

安装Python代码环境参考文档

2. 代码块

python 复制代码
import random

# 准备一下你想吃的东西
hot = ["兰州拉面", "爆肚面", "黄焖鸡", "麻辣香锅", "米线", "麻食", "羊肉泡馍", "肚丝/羊血汤", "米饭快餐", "大盘鸡盖面", "酸菜鱼", "油泼面", "饺子", "砂锅"]
cold = ["凉皮和肉夹馍", "凉面"]

# 选项
weather = input("想吃什么就选择对应的数字吧\n1. 想吃冷的;\n2. 想吃热的;\n3. 冷热都要吃!\n你的选择是?: ---> ")

if weather.isdigit():
    if weather == 1:
        for i in random.choices(cold):
            print("今天中午吃:{}".format(i))
    elif weather == 2:
        for i in random.choices(hot):
            print("今天中午吃:{}".format(i))
    else:
        food = hot + cold
        for i in random.choices(food):
            print("今天中午吃:{}".format(i))
else:
    print("选错了,只能选 1/2/3 任意一个数字!!!")
相关推荐
梯度下降者27 分钟前
Python - 函数
python·高阶函数·可调用对象·functools·嵌套作用域
starzy19902 小时前
深入理解Scala隐式参数:上下文流转
开发语言·python·scala
wuyk5553 小时前
Spider-第16讲-线程池与竞态问题
大数据·爬虫·python·elasticsearch·搜索引擎
kyle~9 小时前
FastAPI --- 将业务能力以 API 的形式提供给外部系统
python·fastapi·前后端
aiotto资源分享10 小时前
Python 写 JSON 文件,程序中途退出会留下什么?
java·python·json·jsondecodeerror
梯度下降者11 小时前
Python信号量,条件变量,事件学习
python·条件变量·事件·信号量·线程通信
MSTcheng.11 小时前
【AI应用实战】用 FastAPI + SSE 做一个自己的 AI 聊天网页:流式输出、多轮对话与完整源码
人工智能·python·大模型·fastapi·sse·ai聊天助手
the局外人12 小时前
Python 实战检索优化:BM25、向量与重排
数据库·后端·python
__underline__12 小时前
冷门Python知识点006篇:Python 类体里的名字,能被"凭空造出来"
后端·python
用户03321266636713 小时前
使用 Python 轻松移除 Excel 文档中的重复行
python·excel