鱼C论坛

 找回密码
 立即注册
查看: 4295|回复: 1

[已解决]登陆系统

[复制链接]
发表于 2017-5-4 14:54:33 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

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:50:17
本帖最后由 新房客 于 2017-5-4 17:54 编辑

if command == 'n' or 'N' 相当于 if command == ‘n’or if 'N'
所以它总是对的,然后会执行register()。应当修改为:if (command == 'n') or (command == 'N')
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2017-5-4 17:50:17 | 显示全部楼层    本楼为最佳答案   
本帖最后由 新房客 于 2017-5-4 17:54 编辑

if command == 'n' or 'N' 相当于 if command == ‘n’or if 'N'
所以它总是对的,然后会执行register()。应当修改为:if (command == 'n') or (command == 'N')
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-7-22 23:29

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表