how encode pdf , word files in folder base64 , decode them , save same folder? pdf , word files generated dynamically through web service.
i use python so.
i used this. gives 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"))
the base64
module, included in standard lib. documentation here.
Comments
Post a Comment