#1、编写文件copy工具
oldpath=input('请输入源文件地址:')
newpath=input('请输入新文件存放地址: ')
with open(oldpath,mode='rt',encoding='utf-8')as file1,\
open(newpath,mode='wt',encoding='utf-8')as file2:
res=file1.read()
file2.write(res)
print('复制完成!')
#2、编写登录程序,账号密码来自于文件
with open('pwd.txt',mode='rt',encoding='utf-8')as file1:
for i in file1:
name,pwd=i.strip().split(':')
if name==username and password==pwd:
print('登录成功!')
break
else:
print('登录失败!')
#3、编写注册程序,账号密码来存入文件
username=input('请输入你的账号:')
password=input('请输入你的密码: ')
with open('new_pwd.txt',mode='at+',encoding='utf-8') as file1:
res=('{}:{}\n'.format(username,password))
file1.write(res)