3.13作业

1、编写文件copy工具

src_file=input('源文件路径>>: ').strip()
dst_file=input('源文件路径>>: ').strip()
with open(r'{}'.format(src_file),mode='rt',encoding='utf-8') as f1,
    open(r'{}'.format(dst_file),mode='wt',encoding='utf-8') as f2:
    res=f1.read()
    f2.write(res)

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

inp_name=input('your name:').strip()
inp_pwd=input('your pwd:').strip()
with open(r'users.txt',mode='rt',encoding='utf-8') as f:
    for i in f:
        username,password=i.strip().split(':')
        if inp_name == username and inp_pwd == password:
            print('登录成功')
            break
    else:
        print('用户名或密码错误')

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

name=input('your name>>: ')
pwd=input('your name>>: ')
with open(r'users1.txt',mode='at',encoding='utf-8') as f:
    f.write('{}:{}
'.format(name,pwd))
原文地址:https://www.cnblogs.com/linqiaobao/p/12489692.html