How do I encode pdf and word files in a folder to base64 and decode them and save into the same folder? The pdf and word files are generated dynamically through a web service.
I would like to use python to do so.
I used this. But it gives the error Traceback (most recent call last):
File "sample.py", line 7, in base64.encode(open("hello.pdf"), open("hello1.b64", "w")) File "C:\Python34\lib\base64.py", line 496, in encode s = input.read(MAXBINSIZE) File "C:\Python34\lib\encodings\cp1252.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 1340: character maps
base64.encode(open("hello.pdf"), open("hello1.b64", "w"))