• ⅩⅡ:作业


    1、通用文件copy工具实现

    src_file=input('源文件路径: ').strip()
    dst_file=input('目标文件路径: ').strip()
    with open(r'%s' %src_file,mode='rb') as read_f,open(r'%s' %dst_file,mode='wb') as write_f:
        for line in read_f:
            print(line)
            write_f.write(line)
    

    2、基于seek控制指针移动,测试r+、w+、a+模式下的读写内容

    with open(r'a.txt', 'r+t') as f:
        print(f.read()) 
        f.seek(5, 0)  
        print(f.tell()) 
        f.write('aaa')
        f.seek(0, 0)
        print(f.read())
    
    with open(r'a.txt', 'w+t') as f:
        print(f.read()) 
        f.seek(5, 0)  
        print(f.tell()) 
        f.write('aaa')
        f.seek(0, 0)
        print(f.read())
    
    with open(r'a.txt', 'a+t') as f:
        print(f.read())
        f.seek(5, 0)
        print(f.tell())
        f.write('aaa')
        f.seek(0, 0)
        print(f.read())
    

    3、tail -f access.log程序实现

  • 相关阅读:
    drf项目部署到腾讯云
    ruby的DIR.pwd
    ruby+selenium-webdriver测试
    ruby
    ruby类对象和对象
    ruby的实例变量
    ruby在类中访问@,类外访问调用方法
    ruby中=>是什么意思
    ruby
    css content属性
  • 原文地址:https://www.cnblogs.com/qujiu/p/12507294.html
Copyright © 2020-2023  润新知