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

    #1、通用文件copy工具实现
    # file1=input('源文件路径>>: ').strip()
    # file2=input('源文件路径>>: ').strip()
    # with open(r'{}'.format(file1),mode='rb') as f1,
    # open(r'{}'.format(file2),mode='wb') as f2:
    # for line in f1:
    # f2.write(line)


    #2、基于seek控制指针移动,测试r+、w+、a+模式下的读写内容
    # with open('d.txt',mode='r+',encoding='utf-8') as f:
    # print(f.read())
    # f.seek(9,0)
    # print(f.tell())
    # f.write("11") #写入两个字节
    # f.seek(9, 0) #回到写入前
    # print(f.read()) #读出写入内容

    # with open('d.txt',mode='w+',encoding='utf-8') as f:
    # print(f.read())
    # f.seek(9,0)
    # print(f.tell())
    # res=f.write("11")
    # print(f.read()) #从11后面开始读不到内容

    # with open('d.txt',mode='a+',encoding='utf-8') as f:
    # print(f.read()) #读不出内容
    # print(f.tell()) #指针在末尾的9
    # f.write("11") #写入两个字节
    # f.seek(9, 0) #回到写入前
    # print(f.read()) #读出写入内容



    #3、tail -f access.log程序实现
    cmd=input("请输入信息:")
    with open('db.txt',mode='a+',encoding='utf-8')as f:
    f.write(cmd)
    f.seek(0,0)
    print(f.read())
  • 相关阅读:
    一些至理名言
    移除快捷方式上面那个丑陋的小箭头
    一些浏览器插件
    yahoo给出的关于网站优化的建议
    javascript 事件流
    关于mongodb的一些笔记
    WebStorm
    给go添加各种package
    工具类 util.Date 日期类
    几种简单排序算法
  • 原文地址:https://www.cnblogs.com/chenyoupan/p/12507025.html
Copyright © 2011-2022 走看看