zoukankan      html  css  js  c++  java
  • 文件处理作业

    #一:今日作业:
    #1、编写文件copy工具
    a = input('输入就文件名:')
    b = input('输入新文件名:')
    with open(r'{}'.format(a), mode='rt', encoding='UTF-8') as f, open(r'{}'.format(b),mode='wt',encoding='UTF-8') as l:
        res = f.read()
        l.write(res)
        
        
    #2、编写登录程序,账号密码来自于文件
    inp_name = input('输入账号:')
    inp_paw = input('输入密码:')
    with open(r'a.txt', mode='rt', encoding='utf-8') as f:
        for line in f:
            name,pwd = line.strip().split(':')
            if name == inp_name and pwd == inp_paw:
                print('登入成功')
                break
        else:
            print('登入失败')
            
            
    #3、编写注册程序,账号密码来存入文件
    inp_name = input('输入账号:')
    inp_paw = input('输入密码:')
    with open(r'a.txt', mode='rt',encoding='utf-8') as f:
        for line in f:
            name, pwd = line.strip().split(':')
            if name == inp_name:
                print('账号已存在')
                break
        else:
            with open(r'a.txt', mode='at', encoding='utf-8') as f:
                f.write('{}:{}
    '.format(inp_name,inp_paw))
                print('注册成功')
  • 相关阅读:
    Android中ProgressBar显示小数的方法
    Android屏幕适配-安卓切图
    android -services
    Java 位移运算符
    异常、集合、数据结构
    常用类
    编码
    String类
    Android-1
    ButterKnife注解式绑定控件
  • 原文地址:https://www.cnblogs.com/bk134/p/12488241.html
Copyright © 2011-2022 走看看