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 任意一个数字!!!")
相关推荐
Flittly2 小时前
【从零手写 ClaudeCode:learn-claude-code 项目实战笔记】(3)TodoWrite (待办写入)
python·agent
千寻girling6 小时前
一份不可多得的 《 Django 》 零基础入门教程
后端·python·面试
databook10 小时前
探索视觉的边界:用 Manim 重现有趣的知觉错觉
python·动效
明月_清风11 小时前
Python 性能微观世界:列表推导式 vs for 循环
后端·python
明月_清风11 小时前
Python 性能翻身仗:从 O(n) 到 O(1) 的工程实践
后端·python
helloweilei1 天前
python 抽象基类
python
用户8356290780511 天前
Python 实现 PPT 转 HTML
后端·python
zone77391 天前
004:RAG 入门-LangChain读取PDF
后端·python·面试
zone77391 天前
005:RAG 入门-LangChain读取表格数据
后端·python·agent
树獭非懒2 天前
AI大模型小白手册|Embedding 与向量数据库
后端·python·llm