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

    1、通用文件copy工具实现

    y_file=input('源文件路径:').strip()
    m_file=input('目标文件路径:').strip()
    with open(r'{}'.format(y_file),mode='rb') as f1,
        open(r'{}'.format(m_file),mode='wb') as f2:
        for i in f1:
            f2.write(i)
        else:
            print('拷贝成功')
    

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

    with open(r'a.txt',mode='r+',encoding='utf-8') as f:
        # f.seek(7,0)
        # print(f.read())#指针移到到第7个字符开始读
    
        f.seek(7,0)
        f.write('456')#指针移到到第7个字符开始写,遇到内容则会覆盖
    
    with open(r'a.txt',mode='w+',encoding='utf-8') as f:
        # f.seek(2,0)
        # print(f.read())#不管指针移到到哪里都会清空内容
    
        f.seek(7,0)
        f.write('呵呵呵')#首先清空内容之后按指针位置第7个字符开始写
    
    with open(r'a.txt',mode='a+',encoding='utf-8') as f:
        # f.seek(7,0)
        # print(f.read())#指针移到到第7个字符开始读
    
        f.seek(7,0)
        f.write('臭弟弟')#不管指针在那,都是在后面追加写
    

    3、tail -f access.log程序实现
    小朋友,你是不是有很多问号???

  • 相关阅读:
    解决依赖的moduleBuildConfig.DEBUG总是未false的问题
    android异步处理机制
    Android 5.0 行为变更
    Android 6.0 变更
    Android 7.0 行为变更
    android 8.0变更
    Android 4.4 API
    Android常见问题集锦
    Android笔记汇总目录
    Delphi中Indy 10的安装和老版本的卸载
  • 原文地址:https://www.cnblogs.com/linqiaobao/p/12505801.html
Copyright © 2011-2022 走看看