Skip to content

Instantly share code, notes, and snippets.

@QuantTraderEd
Last active September 26, 2017 05:39
Show Gist options
  • Save QuantTraderEd/a714f8c60bef9d70e4ca64bcfa6dba13 to your computer and use it in GitHub Desktop.
Save QuantTraderEd/a714f8c60bef9d70e4ca64bcfa6dba13 to your computer and use it in GitHub Desktop.
read_out py & read_in.py
# -*- coding: utf-8 -*-
import zlib
import base64
file_path = 'c:/python'
filename = 'encoded_text.text'
filename_write = 'write_in.py'
with open(file_path + '/' + filename, 'r') as f:
text = f.read()
decoded_text = zlib.decompress(base64.b64decode(text))
print decoded_text
fw = open(filename_write, 'w')
fw.write(decoded_text)
fw.close()
# -*- coding: utf-8 -*-
import zlib
import base64
file_path = 'c:/python'
file_name = 'py'
with open(file_path + '/' + filename, 'r') as f:
text = f.read()
f.close()
encoded_text = base64.b64encode(zlib.compress(text, 9))
print encoded_text
@QuantTraderEd
Copy link
Author

new file 'read_in.py'

@QuantTraderEd
Copy link
Author

Update for correct miss part (write->read)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment