zoukankan      html  css  js  c++  java
  • 作业0313

    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:
            username,password=line.strip().split(':')
            if inp_username == username and inp_password == password:
                print('login successful')
                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('{}:{}
    '.format(name,pwd))
    
  • 相关阅读:
    android作业10.21
    安卓10.7作业
    安卓9.30
    9.23作业
    9.17安卓作业
    6.12作业
    5.29作业
    5.28上机作业
    leetcode 219
    策略模式
  • 原文地址:https://www.cnblogs.com/zuiyouyingde/p/12489112.html
Copyright © 2011-2022 走看看