I\'m using a platform that, when you upload pdf\'s to it, converts the pdf with the base64 encode in Python. Then it stores the binary string in the database.
Now I
base64.decode(,)
takes files as args. you want to try
fout.write(base64.decodestring(code))
though your code example is not encoded. Here's a working example:
#!/usr/bin/python
import base64, os
code = 'TXkgYmluYXJ5IHN0cmluZw==\n'
with open(os.path.expanduser('~/Desktop/test.pdf'), 'wb') as fout:
fout.write(base64.decodestring(code))