import sys
while True:
print('\t\t\t 商店登录界面\n')
print("\t\t ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*\n")
print("\t\t\t 1、用户登录\n")
print("\t\t\t 2、用户注册\n")
print("\t\t\t 3、退出系统\n")
print("\t\t ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*\n")
choice = input('请输入您的选择:')
if choice == "1":
#用户需要登录
username = input("请输入你的用户名称:")
password = input("请输入您的用户密码:")
if username == "admin" and password == "1":
#用户登陆成功、
while True:
print('\t\t\t 商城首页\n')
print("\t\t ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*\n")
print("\t\t\t 1、进入购物超市\n")
print("\t\t\t 2、休闲小游戏\n")
print("\t\t\t 3、返回上一层\n")
print("\t\t\t 4、退出系统\n")
print("\t\t ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*\n")
choice = input('请输入您的选择:')
if choice == "1":
#商城
while True:
print('\t\t\t 商城首页\n')
print("\t\t ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*\n")
print("\t\t\t 编号 名称 价格 库存")
print("\t\t\t 1 避孕套 32¥ 12\n")
print("\t\t\t 2 可口可乐 3¥ 32\n")
print("\t\t\t 3、返回上一层\n")
print("\t\t\t 4、退出系统\n")
print("\t\t ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*\n")
choice = input('请输入您的选择:')
#判断购买那个商品
if choice == "1":
amount = int(input("请输入购买数量:"))
price = 32
count = amount * price
print("购买结果是:%s"%(amount * price))
elif choice == "2":
amount = int(input("请输入购买数量:"))
price = 3
count = amount * price
print("购买结果是:%s"%(amount * price))
elif choice == "3":
#放回上一侧
break
elif choice == "4":
#退出程序
sys.exit()
elif choice == "2":
print("小游戏")
elif choice == "3":
#放回上一侧
break
elif choice == "4":
#退出程序
sys.exit()
else:
input("用户名称或者密码错误,请重新登录,按任意键结束")
elif choice == "2":
#用户需要注册
# pass是python的关键字,这段代码目前忽略不计
pass
elif choice == "3":
#退出系统
break
print("game over~~")
小白学python,循环案例购物界面
最新推荐文章于 2023-01-10 13:44:38 发布