Python 字典验证用户名和密码合法性
dic={'Tommy':'123', 'Dora':'456', 'Joyce':'789'} user=input() #输入用户名 password=input() #输入密码 if user not in dic: #判断用户名是否存在 print('unknown username') elif dic[user]!=password: #判断密码是否正确 print('bad password') else: print('correct')
原文地址: https://www.cveoy.top/t/topic/osoE 著作权归作者所有。请勿转载和采集!