====== 압축 ====== ===== Text 압축 ===== python을 이용한 텍스트 압축 #-*-coding: utf-8-*- data = r""" Wikipedia (Listeni/ˌwɪkɨˈpiːdiə/ or Listeni/ˌwɪkiˈpiːdiə/ WIK-i-PEE-dee-ə) is a free-access, free content Internet encyclopedia, supported and hosted by the non-profit Wikimedia Foundation. Anyone who can access the site[6] can edit almost any of its articles.[not in citation given] Wikipedia is the seventh-most popular website[5] and constitutes the Internet's largest and most popular general reference work.[7][8][9] """ #print data.decode('utf-8') print "LEN: %d" % len(data) raw_input() cdata = data.encode('zlib').encode('base64') print cdata print "LEN: %d" % len(cdata) raw_input() rdata = cdata.decode('base64').decode('zlib') #print rdata.decode('utf-8') print "LEN: %d" % len(rdata) 위 예에서 435자를 394자로 압축 함, 압축된 코드는 아래와 같이 ascii 문자 만으로 구성되어 있음 eJxVUDtOw0AQ7XOK1wFSnFT8SoogRVDQpbBcbNbjeGRn1todE/kGFBS0uQHiJlYuxWYDglQ7n32/ may44Y5KNrh85qAkPD+878avZvw8vHV8+Ch53M/hPM7X/H+7Wj5lnL0sFllJlI37K3CAQeVjZ6yl EKapgXUSORTL+HghBYkdbOuSgylC33XOK5UwUqJ24ViuB2hNECdZ513FiqPnbfL86HopjbKTGR5k cELY1Q7WCE66CRpYKb8p0jjCFKbdRu4oMsBVYI1mvbJtKcxycQoWWNbEiw2/khT4uxP/kFKca50l ps51fWs8drROYtdFShDjBmXtlU6Y39gXAfH3hpKHEmcUGxLypoWninw8T0zkfDPLb4v8rsjvi8k3 ii2k7g== ===== 압축 모듈 ===== * https://github.com/facebook/zstd * http://google.github.io/snappy/