#!/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()
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
#!/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()
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
#!/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
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
#!/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