1. 環境安裝
安裝Python代碼環境參考文檔
2. 代碼塊
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 + coldfor i in random.choices(food):print("今天中午吃:{}".format(i))
else:print("選錯了,只能選 1/2/3 任意一個數字!!!")