zoukankan      html  css  js  c++  java
  • 作业第十一天

    #一:今日作业:
    #1、编写文件copy工具
    file_1=input('请输入复制文件路径:')
    file_2=input('请输入粘贴文件路径:')
    with open(r'{}'.format(file_1),mode='rt',encoding='utf-8') as f1,open(r'{}'.format(file_2),mode='wt',encoding='utf-8') as f2:
    res=f1.read()
    f2.write(res)
    #2、编写登录程序,账号密码来自于文件
    inp_user = input("请输入用户名:").strip()
    inp_pwd = input("请输入用户密码:").strip()
    with open(r'user.txt', 'rt', encoding='utf-8') as f:
    for line in f:
    user, pwd = line.strip().split('=')
    if user == inp_user and pwd == inp_pwd:
    print('login success')
    break
    else:
    print('用户名或密码错误')

    #3、编写注册程序,账号密码来存入文件
    username=input('请输入用户名:')
    pwd=input('请输入用户密码:')
    with open('user.txt',mode='at ',encoding='utf-8') as f:
    f.write('{}:{}\n'.format(username,pwd))
  • 相关阅读:
    java 使用相对路径读取文件
    appium 使用过程问题踩坑-笔记
    CentOS下启动Tomcat
    jodis遇到的问题
    CentOS 7.0 防火墙
    sentinel
    keepalived
    在Tomat7上使用Redis保存Session
    Log4j 使用
    java路径问题
  • 原文地址:https://www.cnblogs.com/lijunc/p/12487698.html
Copyright © 2011-2022 走看看