作业6

1编写文件copy工具

ser_file=input('请输入文件路径:').strip()
res_file=input('请输入文件路径:').strip()
with open('{}'.format(ser_file),mode='rt',encoding='utf-8') as f1,\
    open('{}'.format(res_file),mode='wt',encoding='utf-8') as f2:
    res=f1.read()
    res2=f2.write(res)

2、编写登录程序,账号密码来自于文件

username=input('请输入你的账号:').strip()
password=input('请输入你的密码:').strip()
with open('a.txt',mode='rt',encoding='utf-8') as f1:
    for line in f1:
        inp_name,inp_pwd=line.strip().split(':')
        if username==inp_name and password==inp_pwd:
            print('登录成功!')
            break
    else:
        print('登陆失败!')

3、编写注册程序,账号密码来存入文件

username = input('请输入你要注册的用户名:')
password = input('请输入你要注册的密码:')
with open('a.txt',mode='w',encoding='utf-8') as f:
    f.write('{}\n{}'.format(username,password))
print('恭喜您,注册成功')
posted @ 2020-03-13 15:57  小子,你摊上事了  阅读(76)  评论(0)    收藏  举报