zoukankan      html  css  js  c++  java
  • python 读取大文件,按照字节读取

    def read_bigFile():
        f = open("123.dat",'r')
        cont = f.read(10)
        while len(cont) >0 :
            print(cont)
            cont = f.read(10)
      f.close()
    read_bigFile()
    def copyFile():
        f1 = "123.dat"
        f2 = "123.dat.bak"
        #大文件复制
        fs1 = open(f1,'r')
        fs2 = open(f2,'w')
        cont1 = fs1.readline()
    
        while len(cont1)>0:
            #写入
            fs2.write(cont1)
            cont1 = fs1.readline()
        fs1.close()
        fs2.close()
    copyFile()
  • 相关阅读:
    个人博客
    个人博客
    个人博客
    个人博客
    个人博客
    个人博客
    个人博客
    5.14
    5.13
    5.12
  • 原文地址:https://www.cnblogs.com/rocky-AGE-24/p/7638007.html
Copyright © 2011-2022 走看看