鱼C论坛

 找回密码
 立即注册

【Python学习笔记】设计登陆功能

已有 520 次阅读2016-12-24 13:02 | Python

def NewUser(infoList):
    userAcnt = raw_input('Please create your account:')
    while userAcnt in infoList.keys():
        print 'The name have been used!\n'
        #NewUser(infoList) 
        userAcnt = raw_input('Please create your account:')
    userPasswd = raw_input('Please input your password:')
    infoList[userAcnt] = userPasswd

def LoginUser(infoList):
    userAcnt = raw_input('Please in_put your account:')
    while userAcnt not in infoList.keys():
        print 'The name is not existed!\n'    
        userAcnt = raw_input('Please in_put your account:')
        if userAcnt == 'quitnow':
            return None
    userPasswd = raw_input('Please in_put your password:')
    while infoList[userAcnt] != userPasswd:
        print 'The password is wrong!'
        userPasswd = raw_input('Please in_put your password:')
    print 'Welcome to the system!\n'


def sysDesk():
    print '|---Create an new user: N/n---|'
    print '|---Login your account: E/e---|'
    print '|---   Quit    system : Q/q---|'
    infoList = dict()
    usercom = raw_input('Please in_put command:')
    while(1): 
        if usercom in ('N','n'):
            NewUser(infoList)
        elif usercom in ('E','e'):
            LoginUser(infoList)            
            return None
        elif usercom in ('Q','q'):
            print 'The system is closed\n'
            return None
        else: print 'Wrong command(only 1-3)\n'
        print '\n'
        usercom = raw_input('Please in_put command:')


路过

雷人

握手

鲜花

鸡蛋

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 立即注册

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-7-6 18:06

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

返回顶部