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 任意一个数字!!!")
相关推荐
花酒锄作田11 小时前
使用 pkgutil 实现动态插件系统
python
前端付豪15 小时前
LangChain链 写一篇完美推文?用SequencialChain链接不同的组件
人工智能·python·langchain
曲幽15 小时前
FastAPI实战:打造本地文生图接口,ollama+diffusers让AI绘画更听话
python·fastapi·web·cors·diffusers·lcm·ollama·dreamshaper8·txt2img
老赵全栈实战16 小时前
Pydantic配置管理最佳实践(一)
python
阿尔的代码屋21 小时前
[大模型实战 07] 基于 LlamaIndex ReAct 框架手搓全自动博客监控 Agent
人工智能·python
AI探索者2 天前
LangGraph StateGraph 实战:状态机聊天机器人构建指南
python
AI探索者2 天前
LangGraph 入门:构建带记忆功能的天气查询 Agent
python
FishCoderh2 天前
Python自动化办公实战:批量重命名文件,告别手动操作
python
躺平大鹅2 天前
Python函数入门详解(定义+调用+参数)
python
曲幽2 天前
我用FastAPI接ollama大模型,差点被asyncio整崩溃(附对话窗口实战)
python·fastapi·web·async·httpx·asyncio·ollama