Last active
September 26, 2017 05:39
-
-
Save QuantTraderEd/a714f8c60bef9d70e4ca64bcfa6dba13 to your computer and use it in GitHub Desktop.
read_out py & read_in.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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 |
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
new file 'read_in.py'