字典-小练习
user = {'whx':'whx','123':'123','qwe':'qwe'}
1.验证username,pssd存在于字典中
方法一:
username = input("账号:").strip()
pssd = input("密码:").strip() if username in line:
if user[username] == pssd: print("成功")
方法二:
username = input("账号:").strip() passwd = input("密码:").strip() for info,passwd in user.items(): if info == usename and passwd == pwd: print("成功!")
人生的旅途,前途很远,也很暗。然而不要怕,不怕的人的面前才有路。