标签:out color ide 密码 bin lap closed write iges
#!/usr/bin/env python from qq.lib.a2 import register from qq.lib.a3 import login def main(): while True: choice = input("登陆:1,注册:2") if choice == "1": user = input("用户名:") pwd = input("密码:") ret = login(user, pwd) if ret: print("登录成功") break else: print("登录失败") elif choice == "2": user = input("用户名:") pwd = input("密码:") ret = register(user, pwd) if ret: print("注册成功") break else: print("注册失败") if __name__ == "__main__": main()
#!/usr/bin/env python import hashlib def md5(arg): ooo = hashlib.md5(bytes(‘taochen‘, encoding=‘utf-8‘)) ooo.update(bytes(arg, encoding=‘utf-8‘)) return ooo.hexdigest()
#!/usr/bin/env python import hashlib from qq.lib.a1 import md5 def register(user, pwd): with open(‘db‘, ‘a‘, encoding=‘ utf-8‘) as f: temp = md5(user) + ‘|‘ + md5(pwd) f.write(temp + "\n") return True
#!/usr/bin/env python import hashlib from qq.lib.a1 import md5 def login(user,pwd): with open(‘db‘, ‘r‘, encoding=‘utf-8‘) as f: for line in f: u, p = line.strip().split(‘|‘) if u == md5(user) and p ==md5(pwd): return True return False
if __name__ == "__main__": 的使用
标签:out color ide 密码 bin lap closed write iges
原文地址:http://www.cnblogs.com/shiluoliming/p/6399401.html