设计了一个小程序,模拟支付宝的集五福活动
import randomhappy = {
"1": {"name": "富强福", "num": 0},
"2": {"name": "和谐福", "num": 0},
"3": {"name": "友善福", "num": 0},
"4": {"name": "爱国福", "num": 0},
"5": {"name": "敬业福", "num": 0}
}
print("集五福,迎新春~\n")
while True:
start = input("按下<Enter>键集五福,迎新春")
if isinstance(start, str):
number = random.randint(1, 5)
for k, v in happy.items():
if str(number) == k:
v["num"] = v["num"] + 1
print("获取到: {}".format(v["name"]))
print("当前拥有的福:")
for k, v in happy.items():
print(v["name"], ":", v["num"], end="\t\t")
print("\n")
有什么地方需要优化吗?
1.可以退出
2.合成五福
3.查看每种福的张数
等等... 弄个图形界面最好 思路不错,网上也有许多类似的,可供参考 https://blog.csdn.net/weixin_43931151/article/details/104203003
想要出作品发布,就搞个GUI吧,把五福图片加上,会很不错滴 fish_nian 发表于 2021-7-9 21:33
弄个图形界面最好
还没看到,目前实现不了.. 青出于蓝 发表于 2021-7-9 21:35
思路不错,网上也有许多类似的,可供参考 https://blog.csdn.net/weixin_43931151/article/details/1042030 ...
本来想让你们给具体思路,没想到你们比我还懒 {:10_254:}
页:
[1]