Created
May 27, 2014 07:22
-
-
Save syntaxsugar/9c5cb086965e69fd1444 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import StringIO | |
| import zipfile | |
| def foobar(): | |
| in_memory = StringIO.StringIO() | |
| z = zipfile.ZipFile(in_memory, 'a') | |
| z.writestr("file.txt", 'some data') | |
| z.writestr("file2.txt", 'some data2') | |
| z.close() | |
| in_memory.seek(0) | |
| return in_memory.read() | |
| def main(): | |
| data = foobar() | |
| print type(data) | |
| print len(data) | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment