import random while 1: print("***************购物系统***************") print(" 1.注册用户 ") print(" 2.登录系统 ") print(" 3.退出 ") print("***************购物系统***************") num=int(input("请选择,输入数字:")) if num==1: print("***********欢迎进入注册系统************") member="null" while member=="null": member="ture" name1 = input("请输入用户名:") password1 = input("请输入密码:") password2 = input("请再次输入密码:") telephone = input("请输入电话号码:") if len(name1) < 3: print("用户名的长度不能小于3.") member = "null" continue if len(password1) < 6: print("密码长度不能小于6") member = "null" continue if password1[0] not in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYZ0123456789": #password1[0] not in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYZ0123456789":可以等价于一个函数: print("密码由数字或字母构成。") member = "null" continue if password1 != password2: print("两次的输入密码不相同。") member = "null" continue if telephone[0] not in "1" or len(telephone) != 11: print("无效的手机号码。") member = "null" continue else: print("**注册成功!") huiyuan=random.randint(1000,10000) print("**会员ID:C-%d"%(huiyuan)) print("**会员用户名:%s"%name1) continue if num==2: point = 0 member = "null" while point < 3: point+=1 if member=="null": name=input("请输入用户名:") password=input("请输入密码:") if name==name1 and password==password1 : while 1: print("*************欢迎进入购物系统*************") print(" 1.客户信息管理 ") print(" 2.购物结算 ") print(" 3.真情回馈 ") print(" 4.注销 ") print("*************欢迎进入购物系统*************") num1 = int(input("请选择,输入数字:")) if num1==1: print("该用户是本店的会员:") elif num1 == 2: a = "购物系统" b = "购物清单" print(f"{a:*^40}") print(f"{'商品编号': <8}", f"{'商品名称': <8}", f"{'商品价格': ^8}") goship = [] num = 0.0 while 1: products = [[1, "XX手机", 4480.00], [2, "XXX电脑", 6480.00], [3, "XXX耳机", 480.00], [4, "XX运动鞋", 280.00], [5, "XXX钢笔", 18.00]] for i in range(len(products)): print(f"{products[i][0]: ^5}", f"{products[i][1]: ^18}", f"{products[i][2]:.2f}") business = input("请选择您要购买的商品(结束购物请输入q):") if business == "q": print(f"{b:*^40}") print(f"{'商品名称': <8}", f"{'商品价格': <8}", f"{'商品数量': ^8}", f"{'商品总价': ^8}") for i in range(len(goship)): print(f"{goship[i][0]: ^5}", f"{goship[i][1]:11.2f}", f"{goship[i][2]: ^15}", f"{goship[i][3]:8.2f}") num = num + goship[i][3] print("你的购物总金额是:%.2f元" % num) break number = int(input("请选择购买的数量:")) pro = [products[int(business) - 1][1], products[int(business) - 1][2], number, products[int(business) - 1][2] * number] goship.append(pro) elif num1==3: print("感谢小伙伴们对我们超市的使用,暂时还未有活动敬请期待!") elif num1==4: print("感谢小伙伴们对我们超市的使用,再见!") member="no" break break else: print("用户名或密码错误,请重新登录!") else: print("登录超过三次,请稍后再试。") elif num==3: print("***************购物系统***************") print(" 谢谢光临 ") print("***************购物系统***************") break else: print("***************购物系统***************") print(" 选择有误,再见! ") print("***************购物系统***************") break
使用python实现超市管理系统(粗略)
于 2024-04-22 15:33:48 首次发布
文章描述了一个基于Python编写的简易购物系统,包括用户注册、登录验证、购物结算等功能。
摘要由CSDN通过智能技术生成