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 任意一个数字!!!")
相关推荐
AI探索者15 小时前
LangGraph StateGraph 实战:状态机聊天机器人构建指南
python
AI探索者15 小时前
LangGraph 入门:构建带记忆功能的天气查询 Agent
python
FishCoderh17 小时前
Python自动化办公实战:批量重命名文件,告别手动操作
python
躺平大鹅17 小时前
Python函数入门详解(定义+调用+参数)
python
曲幽18 小时前
我用FastAPI接ollama大模型,差点被asyncio整崩溃(附对话窗口实战)
python·fastapi·web·async·httpx·asyncio·ollama
两万五千个小时21 小时前
落地实现 Anthropic Multi-Agent Research System
人工智能·python·架构
哈里谢顿1 天前
Python 高并发服务限流终极方案:从原理到生产落地(2026 实战指南)
python
用户8356290780512 天前
无需 Office:Python 批量转换 PPT 为图片
后端·python
markfeng82 天前
Python+Django+H5+MySQL项目搭建
python·django
GinoWi2 天前
Chapter 2 - Python中的变量和简单的数据类型
python