微信小程序> 小程序之用户管理系统

小程序之用户管理系统

浏览量:2236 时间: 来源:蘇慜

       写一个小程序实现用户的管理,即用户注册,用户登录,用户信息显示,用户注销


#coding:utf-8print """    1.注册新用户    2.登录用户    3.显示用户信息    4.注销用户    5.退出"""info = {    'user1': {        'name': 'user1',        'password': '123',        'gender': '0',  ##0-male,1-female,2-others,        'email': 'user1@westos.org',        'age': '14'    }}def createUser():    print "注册新用户".center(40, "*")    username = raw_input("username:")    if username in info:        print "用户已存在"    else:        password = raw_input("password:"),        gender = input("gender(0-male,1-female,2-other):"),        email = raw_input("email:"),        age = input("age:")        info[username] = {            'name': username,            'password': password,            'genter': genter,            'email': email,            'age': age,        }        print "%s 注册成功" % (username)def login():    print "用户登录".center(40, "*")    i = 0    while i < 3:        inname = raw_input("username:")        if not inname in info:            print "用户未注册"            break        inpassword = raw_input("password:")        if inpassword == info[inname]['password']:            print "登陆成功"            exit()        else:            print "登录失败"            break             ##退出异常        i += 1    else:        print "登陆超过三次,请稍后登陆"def showUser():    print "显示用户信息".center(40, "*")    inname = raw_input("username:")    if inname in info:        for inname in info:            print info[inname]    else:        print "该用户不存在"def delUser():    inname = raw_input("username:")    if not inname in info:        print "用户未注册"    else:        inpassword = raw_input("password:")        if inpassword == info[inname]['password']:            info.pop("inname")        print "该用户已注销!"while True:    choice = raw_input("你的选择:")    if choice == "1":        ##注册新用户        createUser()    elif choice == "2":        ##登录用户        login()    elif choice == "3":        ##显示用户信息        showUser()    elif choice == "4":        ##注销用户        delUser()    elif choice == "5":        ##退出        exit()    else:        print " 请输入合法选择!"

版权声明

即速应用倡导尊重与保护知识产权。如发现本站文章存在版权问题,烦请提供版权疑问、身份证明、版权证明、联系方式等发邮件至197452366@qq.com ,我们将及时处理。本站文章仅作分享交流用途,作者观点不等同于即速应用观点。用户与作者的任何交易与本站无关,请知悉。

产品经理

手机 : 13312967497

擅长 : 小程序流量变现

扫码领取礼包

最新资讯

热门模板

  • 头条
  • 搜狐
  • 微博
  • 百家
  • 一点资讯
  • 知乎