Python基础——外卖管理系统和闭组会议总结

外卖管理系统

用户、管理员、菜单

菜单

def main():
    option = input("用户请按1\n管理员请按2\n")
    if option == "1":
        menu1()
    if option == "2":
        menu2()
def menu1():
    global ID
    login = False
    while True:
        print(menu(login))
        try:
            choice = int(input("请输入:"))
            if choice in [0, 1, 2, 3, 4, 5, 6, 7, 8]:
                if choice == 0:
                    answer = input("您确定退出系统吗?y/n:")
                    if answer == "y":
                        print("感谢您的使用")
                        break
                if choice == 1:
                    register()
                elif choice == 2:
                    result = post()
                    login = result[0]
                    ID = result[1]
                if login:
                    if choice == 3:
                        modify_passwd(ID)
                    elif choice == 4:
                        insert(ID)
                    elif choice == 5:
                        search(ID)
                    elif choice == 6:
                        modify_num(ID)
                    elif choice == 7:
                        addmoney(ID)
                    elif choice == 8:
                        delete(ID)
            else:
                print("输入有误,请重新输入")
        except:
            print("输入有误,请重新输入")
def menu2():
    a = input("请输入管理员名称:")
    b = input("请输入密码:")
    if a == "kk" and b == "kkk":
        print("管理员登录成功")
    else:
        print("输入错误,请重新输入")
        return menu2()
    while True:
        print(menu_())
        choice = int(input("请输入:"))
        if choice in [0, 1, 2, 3, 4, 5, 6]:
            if choice == 0:
                answer = input("您确定退出系统吗?y/n:")
                if answer == "y":
                    print("感谢您的使用")
                    break
            if choice == 1:
                modify_passwd_()
            elif choice == 2:
                insert_()
            elif choice == 3:
                search_()
            elif choice == 4:
                delete_()
            elif choice == 5:
                modify_num2()
            elif choice == 6:
                delete2()
        else:
            print("输入有误")
def menu(login):
    if login:
        w = """
                  ====================================================外卖管理系统=====================================================
                  -------------------------------------------------功能选择-----------------------------------------------------------
                 \t\t\t\t0.是否继续使用系统
                 \t\t\t\t1.注册
                 \t\t\t\t2.登录
                 \t\t\t\t3.修改密码
                 \t\t\t\t4.增加订单信息
                 \t\t\t\t5.查找订单信息
                 \t\t\t\t6.修改订单信息
                 \t\t\t\t7.充值
                 \t\t\t\t8.注销用户
                 --------------------------------------------------------------------------------------------------------------------
                 ====================================================================================================================
             """
        return w
    else:
        w = """
                    ====================================================外卖管理系统=====================================================
                    -------------------------------------------------功能选择-----------------------------------------------------------
                   \t\t\t\t0.是否继续使用系统
                   \t\t\t\t1.注册
                   \t\t\t\t2.登录
                   --------------------------------------------------------------------------------------------------------------------
                   ====================================================================================================================
                   """
        return w
def menu_():
    ww = """
                  ====================================================外卖管理系统=====================================================
                  -------------------------------------------------功能选择-----------------------------------------------------------
                 \t\t\t\t0.是否继续使用系统
                 \t\t\t\t1.修改用户密码
                 \t\t\t\t2.增加订单信息
                 \t\t\t\t3.查找订单信息
                 \t\t\t\t4.删除订单信息
                 \t\t\t\t5.修改订单信息
                 \t\t\t\t6.注销用户
                 --------------------------------------------------------------------------------------------------------------------
                 ====================================================================================================================
             """
    return ww

调用函数

if __name__ == '__main__':
    main()

用户

1.注册
def register():
    while True:
        ID = input("请输入用户名:")
        with open('users.txt', 'r', encoding='utf-8') as file_obj:
            fi = file_obj.readlines()
        u = False
        for item in fi:
            d = dict(eval(item))
            if d['ID'] == ID:
                u = True
                print("此用户名已被注册。请重新注册")
                break
        if u:
            continue
        password = input("请输入密码:")
        password_ = input("请确认密码:")
        if not ID or not password or not password_:
            print("用户名或密码不能为空")
            continue
        if password != password_:
            print("两次输入密码不一致,请重新输入")
            continue
        u = {"ID": ID, 'data': {'password': password, 'account': 0}}
        if password == password_:
            with open('users.txt', 'a+', encoding='utf-8') as file_obj:
                file_obj.write(str(u) + "\n")
            print("注册成功,请确认登录")
            login = False
            return menu(login)
2.登录
def post():
    while True:
        ID = input("请输入用户名:")
        password = input("请输入密码:")
        with open("users.txt", "r", encoding="utf-8") as fp:
            m = fp.readlines()
            try:
                for i in m:
                    f = dict(eval(i))
                    if ID == f['ID'] and password == f['data']['password']:
                        print("登录成功")
                        global name
                        name = ID
                        return True, name
                print('用户名或者密码错误,请确认用户名及密码无误后重新尝试,请重新输入')
                c = input("    1.重新登录\n    2.注册账户\n")
                if c == '1':
                    pass
                elif c == "2":
                    register()
                    return False
                else:
                    print('输入错误')
            except:
                print("该用户不存在,请重新输入")

3.修改密码
def modify_passwd(ID):
    lst = []
    with open("users.txt", "r", encoding="utf-8") as file:
        k = file.readlines()
        for i in k:
            lst.append(dict(eval(i)))
    while True:
        password_new = input("请输入您的新密码:")
        password_new_ = input("请确认您的新密码:")
        if password_new == password_new_:
            break
        else:
            print("两次密码不一样")
    for user in lst:
        if user["ID"] == ID:
            user['data']['password'] = password_new
    with open("users.txt", "w+", encoding="utf-8") as file:
        for i in lst:
            file.write(str(i) + "\n")
    print("修改成功")
4.增加订单
import random
def insert(ID):
    while True:
        with open('nums.txt', 'r', encoding='utf-8') as file_obj:
            fi = file_obj.readlines()

        for item in fi:
            d = dict(eval(item))
            if d['ID'] == ID:

                print("此用户名订单已存在。")
                return

        num = random.randint(0, 99999)
        tel = str(input("请输入手机号码:"))
        address = str(input("请输入收货地址:"))
        m = {"ID": ID, 'data': {'num': num, 'tel': tel, 'address': address}}
        print("成功添加信息")
        with open('nums.txt', 'a+', encoding='utf-8') as file_obj:
            file_obj.write(str(m) + "\n")
            return menu_()

5.查找订单信息
def search(ID):
    while True:
        x = 0
        with open("users.txt", "r", encoding="utf-8") as fp:
            m = fp.readlines()
            for i in m:
                f = dict(eval(i))
                if ID == f['ID']:
                    a = f['ID']
                    b = f['data']['account']
                    x = 0
                    break
                else:
                    x += 1
            if x != 0:
                print("未找到该用户,请重新输入")
                break

            y = 0
            with open("nums.txt", "r", encoding="utf-8") as fo:
                h = fo.readlines()
                for g in h:
                    q = dict(eval(g))
                    if ID == q['ID']:
                        c = q['data']['num']
                        d = q['data']['tel']
                        e = q['data']['address']
                        print(f"用户名:{a},账户:{b}元,订单号:{c},电话:{d},收货地址:{e}")
                        y = 0
                        return
                    else:
                        y += 1

                if y != 0:
                    print("未找到该用户的订单信息,请重新输入")
                    break

6.修改订单
def modify_num(ID):
    while True:
        with open("nums.txt", "r", encoding="utf-8") as file:
            a = 0
            lst3 = []
            uu = file.readlines()
            for yy in uu:
                n = dict(eval(yy))
                lst3.append(n)
                if n['ID'] == ID:
                    a = 0
                    break
                else:
                    a += 1
            if a != 0:
                print("没有找到该用户的订单信息,请重新输入")

                return
            cc = input("请选择:\n1.修改手机号\n2.修改收货地址\n3.退出修改\n")
            if cc == "1":
                while True:
                    tel_new = input("请输入新的手机号:")
                    tel_new_ = input("请确认新的手机号:")
                    if tel_new == tel_new_:
                        break
                    else:
                        print("两次手机号输入不一致,请重新输入")
                for user in lst3:
                    if user["ID"] == name:
                        user['data']['tel'] = tel_new
                with open("nums.txt", "w+", encoding="utf-8") as file:
                    for uu in lst3:
                        file.write(str(uu) + "\n")
                print("手机号修改成功")
            if cc == "2":
                while True:
                    tel_new = input("请输入新的收货地址:")
                    tel_new_ = input("请确认新的收货地址:")
                    if tel_new == tel_new_:
                        break
                    else:
                        print("两次收货地址输入不一致,请重新输入")
                for user in lst3:
                    if user["ID"] == name:
                        user['data']['tel'] = tel_new
                with open("nums.txt", "w+", encoding="utf-8") as file:
                    for uu in lst3:
                        file.write(str(uu) + "\n")
                print("收货地址修改成功")
            if cc == "3":
                login = False
                return login

7.充值
def addmoney(ID):
    lst2 = []
    kk = int(input("请输入要充值的金额:"))
    with open("users.txt", "r", encoding="utf-8") as file:
        kkk = file.readlines()
        for ii in kkk:
            lst2.append(dict(eval(ii)))
    for user in lst2:
        if user["ID"] == name:
            a = int(user['data']['account'])
            a += kk
            user['data']['account'] = a
    with open("users.txt", "w+", encoding="utf-8") as file:
        for ii in lst2:
            file.write(str(ii) + "\n")
    print("充值成功")
8.注销用户
def delete(ID):
    while True:
        with open("users.txt", 'r', encoding='utf-8') as fr:
            user_old = fr.readlines()
            user_new = []
            for item in user_old:
                d = dict(eval(item))
                if ID == d['ID']:
                    break
                else:
                    user_new.append(d)
            with open("users.txt", 'w+', encoding='utf-8') as fra:
                for item in user_new:
                    fra.write(str(item) + '\n')
            break
    while True:
        with open("nums.txt", 'r', encoding='utf-8') as frb:
            user_old = frb.readlines()
            user_new = []
            for item in user_old:
                d = dict(eval(item))
                if ID == d['ID']:
                    break
                else:
                    user_new.append(d)
            with open("nums.txt", 'w+', encoding='utf-8') as frb:
                for item in user_new:
                    print(f"ID为{ID}的用户信息已经删除!")
                    frb.write(str(item) + '\n')
            break

管理员

1.修改用户密码
def modify_passwd_():
    a = 0
    pp = input("请输入要修改信息的用户名:")
    lst1 = []
    with open("users.txt", "r", encoding="utf-8") as file:
        ki = file.readlines()
        for i in ki:
            bb = dict(eval(i))
            lst1.append(bb)
        for j in lst1:
            if j['ID'] == pp:
                a = 0
                break
            else:
                a += 1
        if a == 0:
            while True:
                password_new = input("请输入新密码:")
                password_new_ = input("请确认新密码:")
                if password_new == password_new_:
                    break
                else:
                    print("两次密码不一样")
        else:
            print("未查找到该用户,请重新输入")
            return modify_passwd_()
        for users in lst1:
            if users["ID"] == pp:
                users['data']['password'] = password_new
                with open("users.txt", "w+", encoding="utf-8") as file:
                    for i in lst1:
                        file.write(str(i) + "\n")
                print("修改成功")
2.增加订单信息
def insert_():
    while True:
        ID = input("请输入用户名:")
        t = 0
        with open('users.txt', 'r', encoding='utf-8') as file_obj:
            fi = file_obj.readlines()
        for item in fi:
            d = dict(eval(item))
            if d['ID'] == ID:
                t = 0
                break
            else:
                t += 1
        if t != 0:
            print("此用户名未注册,请先注册")
            return

        num = random.randint(1,10000)
        tel = str(input("请输入手机号码:"))
        address = str(input("请输入收货地址:"))
        mn = {"ID": ID, 'data': {'num': num, 'tel': tel, 'address': address}}
        print("成功添加信息")
        with open('nums.txt', 'a+', encoding='utf-8') as file_obj:
            file_obj.write(str(mn) + "\n")
            return menu_()
3.查找订单信息
def search_():
    while True:
        ID = input("请输入用户名:")
        x = 0
        with open("users.txt", "r", encoding="utf-8") as fp:
            m = fp.readlines()
            for i in m:
                f = dict(eval(i))
                if ID == f['ID']:
                    a = f['ID']
                    b = f['data']['account']
                    x = 0
                    break
                else:
                    x += 1
            if x != 0:
                print("未找到该用户,请进行注册")
                break

            y = 0
            with open("nums.txt", "r", encoding="utf-8") as fo:
                h = fo.readlines()
                for g in h:
                    q = dict(eval(g))
                    if ID == q['ID']:
                        c = q['data']['num']
                        d = q['data']['tel']
                        e = q['data']['address']
                        print(f"用户名:{a},账户:{b}元,订单号:{c},电话:{d},收货地址:{e}")
                        y = 0
                        return
                    else:
                        y += 1

                if y != 0:
                    print("未找到该用户的订单信息,请重新输入")
                    break
4.删除订单信息
def delete_():
    while True:
        ID = input("请输入要删除订单信息的用户名:")
        t = 0
        with open("nums.txt", 'r', encoding='utf-8') as fr:
            user_old_ = fr.readlines()
            for items in user_old_:
                d = dict(eval(items))
                if ID == d['ID']:
                    t = 0
                    break
                else:
                    t += 1
            if t != 0:
                print("未找到该用户,请重新输入")
                break
            user_new = []
            for items in user_old_:
                d = dict(eval(items))
                if ID == d['ID']:
                    print(f"ID为{ID}的用户信息已经删除!")
                    continue
                else:
                    user_new.append(d)
            with open("nums.txt", 'w+', encoding='utf-8') as frs:
                for item in user_new:
                    frs.write(str(item) + '\n')
            break
5.修改订单信息
def modify_num2():
    while True:
        ID = input("请输入要修改信息的用户名:")
        t = 0
        lst4 = []
        with open("nums.txt", "r", encoding="utf-8") as file:
            uu = file.readlines()
            for yy in uu:
                h = dict(eval(yy))
                lst4.append(h)
                if ID == h['ID']:
                    t = 0
                    break
                else:
                    t += 1
            if t != 0:
                print("未找到该用户的订单信息,请重新输入")
                break
            else:
                cc = input("请选择:\n1.修改手机号\n2.修改收货地址\n")
            if cc == "1":
                while True:
                    tel_new = input("请输入新的手机号:")
                    tel_new_ = input("请确认新的手机号:")
                    if tel_new == tel_new_:
                        break
                    else:
                        print("两次手机号输入不一致,请重新输入")
                for user in lst4:
                    if user["ID"] == ID:
                        user['data']['tel'] = tel_new
                with open("nums.txt", "w+", encoding="utf-8") as file:
                    for uu in lst4:
                        file.write(str(uu) + "\n")
                print("手机号修改成功")
                break
            if cc == "2":
                while True:
                    tel_new = input("请输入新的收货地址:")
                    tel_new_ = input("请确认新的收货地址:")
                    if tel_new == tel_new_:
                        break
                    else:
                        print("两次收货地址输入不一致,请重新输入")
                for user in lst4:
                    if user["ID"] == ID:
                        user['data']['tel'] = tel_new
                with open("nums.txt", "w+", encoding="utf-8") as file:
                    for uu in lst4:
                        file.write(str(uu) + "\n")
                print("收货地址修改成功")
                break
6.注销用户
def delete2():
    while True:
        ID = input("请输入想要删除的用户:")
        t = 0
        with open("users.txt", 'r', encoding='utf-8') as fr:
            user_old_ = fr.readlines()
            for items in user_old_:
                d = dict(eval(items))
                if ID == d['ID']:
                    t = 0
                    break
                else:
                    t += 1
            if t != 0:
                print("未找到该用户,请重新输入")
                continue
            user_new = []
        for items in user_old_:
            d = dict(eval(items))
            if ID == d['ID']:
                print(f"ID为{ID}的用户信息已经删除!")
                continue
            else:
                user_new.append(d)
        with open("users.txt", 'w+', encoding='utf-8') as frs:
            for item in user_new:
                frs.write(str(item) + '\n')
        break
    while True:
        with open("nums.txt", 'r', encoding='utf-8') as frb:
            user_old = frb.readlines()
            user_new = []
            for item in user_old:
                d = dict(eval(item))
                if ID == d['ID']:
                    break
                else:
                    user_new.append(d)
            with open("nums.txt", 'w+', encoding='utf-8') as frb:
                for item in user_new:
                    frb.write(str(item) + '\n')
            print(f"ID为{ID}的订单信息已经删除!")
            break

闭组会议总结

今天下午小组举行了闭组会议。先是由两位优秀的正在实习的学姐讲述了她们的实习经历,然后是大家的提问环节,最后是每个方向的负责人总结上学期的学习情况。
通过认真听两位学姐分享自己的实习经历,我受益匪浅。因为无论我们将来是选择考研还是就业,到最后都会去找工作的。两位学姐都提出我们要从大一开始练习算法题,力扣的每日一题就是不错的选择。学姐的建议是先独立思考半个小时,如果半个小时后还没有思路,就可以查看题解。通过对题解的认真研究,学会一道题的多种解法。
我们学校的知名度不够,既不是985、211,也不是“双一流”,因此我们更要提升自己的能力,才能在以后的求职中脱颖而出。在求职过程中,要多投简历,“海投”。在我们投简历时,要在简历中突出自己的能力和自己的成果。这就需要我们平时在小组多做项目,才不至于在以后让自己的简历是一片空白。而且多做项目能让我们复习巩固前一阶段所学知识。不过项目看的不止是数量,更重要的是它的质量。学姐还说到要早日去找实习工作,以便自己能够学到更多东西,积累经验。我们的博客也要坚持写,这在以后都是加分项。
想要学好我们这个专业,高数也是必不可少的。
在各个方向负责人总结时,学长说道,我们的成果并不明显。我觉得这是因为我们还没有找到属于自己的方向,找到自己的方向是非常重要的。“如果没有目标地前进,那么任何方向的风都是逆风。”
虽然小组闭组后,对我们的学习时间要求的没有那么严格了,但是我们也要抓紧学习,复习考试科目,不能松懈自己的学习。期待能够成为更好的自己。

  • 5
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值