亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 3838 | 回復(fù): 3
打印 上一主題 下一主題

python gzip MemoryError 問題 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2010-10-14 15:57 |只看該作者 |倒序?yàn)g覽
coinlogroot = r'd:\test.log.gz'
f = gzip.open(coinlogroot, 'rb')
報(bào)錯(cuò):
  File "C:\Python25\lib\gzip.py", line 297, in _add_read_data
    self.extrabuf = self.extrabuf + data
MemoryError
這個(gè)文件有好幾個(gè)G。

論壇徽章:
0
2 [報(bào)告]
發(fā)表于 2010-10-14 16:00 |只看該作者
我以前寫的代碼,你如果是要做gzip檢測(cè)可以用到它
  1. #coding:utf-8


  2. import urllib2
  3. import StringIO,gzip,re
  4. from time import ctime

  5. MANZZBD_PPURLGF = 'http://.+?\..+?\..+'
  6. URLXFPE_RAWORDV = "http://"
  7. WORSPA_SOZGVERT = "http://www."
  8. urlroot=urllib2.HTTPHandler(debuglevel=1)
  9. opener = urllib2.build_opener(urlroot)


  10. class VaurlpathzxcrError(BaseException) : pass
  11. class MrhandirzkanrError(VaurlpathzxcrError) : pass



  12. class URLrOotavrManroot:
  13.    
  14.      def __init__(self,lower):
  15.      
  16.          self.lower = lower
  17.          self.pack  = False
  18.          self.data  = False
  19.          self.cgix  = False
  20.          self.inurlSpcltGagdg()
  21.          self.sooRrootManseek()
  22.          self.vuiBichuHworldn()
  23.       


  24.    #發(fā)送gzip壓縮請(qǐng)求
  25.      def inurlSpcltGagdg(self):
  26.          valchar = urllib2.Request(self.lower,
  27.                 headers={'Accept-encoding':'gzip'})
  28.          self.cgix = opener.open(valchar).read()
  29.       


  30.    #解壓gzip文件
  31.      def sooRrootManseek(self):
  32.          self.pack = self.cgix
  33.          passdir = StringIO.StringIO(self.pack)
  34.          gzipper = gzip.GzipFile(fileobj=passdir)
  35.          self.data = gzipper.read()


  36.    #壓縮前后進(jìn)行對(duì)比
  37.      def vuiBichuHworldn(self):
  38.          if len(self.data) is len(self.cgix):
  39.             raise VaurlpathzxcrError("Don't support the link")
  40.          else:
  41.             print "The current time %s" % ctime()



  42.                                                                                           
  43. class URLcossNoruermoher:
  44.      def __init__(self,hasrrt):
  45.         if   not WORSPA_SOZGVERT in hasrrt:
  46.              hasrrt = WORSPA_SOZGVERT + hasrrt
  47.         if   not URLXFPE_RAWORDV in hasrrt:
  48.              hasrrt = URLXFPE_RAWORDV + hasrrt
  49.         if   re.findall(MANZZBD_PPURLGF,hasrrt):
  50.              self.seek = URLrOotavrManroot(hasrrt)
  51.         else:
  52.              raise MrhandirzkanrError('url requirements specification')
  53.       
  54.    

  55. def main():
  56.      URLcossNoruermoher('http://www.gov.cn/')


  57. if __name__=="__main__":
  58.      main()

  59.    
  60.          
復(fù)制代碼

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2010-10-14 16:04 |只看該作者
謝謝了,我就是想解壓本地的一個(gè)日志文件了,沒有那么復(fù)雜。

論壇徽章:
0
4 [報(bào)告]
發(fā)表于 2010-10-15 09:43 |只看該作者
自己頂一下
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP