小伙伴们,QQ是不是有登陆器?今天我们就来做做吧!
(这里文件名叫:test.py)
#encoding:utf-8
import easygui,os
with open('D:/Desktop/account.txt',encoding='utf-8') as f:
acc = f.read()
with open('D:/Desktop/password.txt',encoding='utf-8') as t:
word = t.read()
if len(acc)<=0 and len(word)<=0:
easygui.msgbox('欸欸欸,你账号和密码都没有欸!')
easygui.msgbox('要不,注册一个?')
a = easygui.enterbox('账号')
b = easygui.enterbox('密码')
with open('D:/Desktop/account.txt','w',encoding='utf-8') as k:
k.write(a)
with open('D:/Desktop/password.txt','w',encoding='utf-8') as o:
o.write(b)
if len(a)>0 and len(b)>0:
easygui.msgbox('注册成功!')
os.system('python test1.py')
else:
easygui.msgbox('注册失败!')
elif len(acc)>0 and len(word)>0:
os.system('python test1.py')
elif len(acc)<=0:
easygui.msgbox('你账号没欸!注册个账号吧!')
ad = easygui.enterbox('账号')
with open('D:/Desktop/account.txt','w',encoding='utf-8') as p:
p.write(ad)
elif len(word)<=0:
easygui.msgbox('你没密码欸!注册一个吧!')
bd = easygui.enterbox('密码')
with open('D:/Desktop/password.txt','w',encoding='utf-8') as b:
b.write(bd)
else:
easygui.msgbox('服务器错误!')
(这里是test1.py的)
# coding:utf-8
import easygui,os
with open('D:/Desktop/account.txt',encoding='utf-8') as f:
ac = f.read()
with open('D:/Desktop/password.txt',encoding='utf-8') as t:
wor = t.read()
if len(ac)<=0 and len(wor)<=0:
os.system('python test.py')
if len(ac)<=0 or len(wor)<=0:
os.system('python test.py')
a = easygui.enterbox('请输入账号')
b = easygui.enterbox('请输入密码')
if a==ac and b==wor:
easygui.msgbox('登录成功!')
else:
easygui.msgbox('登录失败!')
小提醒:那里的'D:/Desktop'这里你们可以自定义,随便一个文件夹都可以。
最重要的一点:一定要在文件夹那里新建一个叫account和password的txt文件。因为作者懒,
不做创建新的了。
喜欢的记得点关注呀!
幻白爱你哟!
|