bz2

2022. 7. 20. 20:00Programming/python

반응형

>> import bz2
>> str = b"sqlplus scott/tiger"

 

# compress

>> compress_str = bz2.compress(str)

>> print(compress_str)

b'BZh91AY&SYY\xf9\xdb\xc5\x00\x00\x07\x11\x80@\x00\x8a\xa4\xfe\x00 \x001\x00\x00\x08@d\xf0\xa1X\xedh\x9b\x14\x18~N\xfe.\xe4\x8ap\xa1 \xb3\xf3\xb7\x8a'

 

# decompress

>> decompress_str = bz2.decompress(compress_str)

>> print(d)

b"sqlplus scott/tiger"

 

>> print(d.decode())
sqlplus scott/tiger

 

 

# 오라클 접속 예시

>> import os

>> os.system(bz2.decompress(compress_str))

 

https://docs.python.org/3/library/bz2.html

 

bz2 — Support for bzip2 compression — Python 3.10.5 documentation

bz2 — Support for bzip2 compression Source code: Lib/bz2.py This module provides a comprehensive interface for compressing and decompressing data using the bzip2 compression algorithm. The bz2 module contains: (De)compression of files bz2.open(filename,

docs.python.org

 

반응형

'Programming > python' 카테고리의 다른 글

동적변수  (0) 2022.07.28