| 
 | 
 
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册  
 
x
 
user={} 
def main(): 
    while True: 
        print('|---New user:N/n---|') 
        print('|---login in:E/e---|') 
        print('|---  Quit: Q/q ---|') 
        command=input('|---Plese enter the conmmand:') 
        if command == 'n' or 'N': 
            register() 
        elif command == 'e' or 'E': 
            login_in() 
             
 
        elif command == 'Q' or 'q': 
            qt() 
        else: 
            print('Please enter the right command .') 
            continue 
 
 
 
 
 
 
 
 
def register(): 
    name=input('Please enter the user\'s name:') 
    if name in user: 
        print('This name has been used,please try another one.') 
    else: 
        password=input('Please enter the password:') 
        user[name]=password 
        print('Registration succeed, try to login in^_^') 
  
def login_in(): 
    name1=input('Please enter your name:') 
    if name not in user: 
        name=input('The name you entered does not exiset,please try again:') 
    else: 
        password=input('Please enter your password:') 
        pwd=user.get(name) 
        if pwd == password: 
            print('Welcome to this system.') 
        else: 
            print('The password is not correct.') 
def qt(): 
    print('You have quited the system, hope your next visit.') 
 
main() 
     
             
 
 
     
求助各位大神    错误在哪,现在新建用户的时候,不管输入的指令是不是n或N,程序都会进行下一步
 本帖最后由 新房客 于 2017-5-4 17:54 编辑  
 
if command == 'n' or 'N' 相当于 if command == ‘n’or if 'N'  
所以它总是对的,然后会执行register()。应当修改为:if (command == 'n') or (command == 'N') 
 
 
 |   
 
 
 
 |