小白学python,循环案例购物界面

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~~")
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值