首页 > 编程语言 > 详细

2020python练习六

时间:2020-03-13 21:43:27      阅读:93      评论:0      收藏:0      [点我收藏+]

2020python练习六

@2020.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_username=input(your name>>: ).strip()
inp_password=input(your password>>: ).strip()

# 验证
with open(user.txt,mode=rt,encoding=utf-8) as f:
    for line in f:
        # print(line,end=‘‘) # egon:123\n
        username,password=line.strip().split(:)
        if inp_username == username and inp_password == password:
            print(login successfull)
            break
    else:
        print(账号或密码错误)

 

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

name=input(your name>>: )
pwd=input(your name>>: )
with open(db.txt,mode=at,encoding=utf-8) as f:
    f.write({}:{}\n.format(name,pwd))

 

2020python练习六

原文:https://www.cnblogs.com/bigorangecc/p/12488931.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!