How to base64 encode a PDF file in Python

前端 未结 4 1032
天命终不由人
天命终不由人 2021-02-04 14:17

How should I base64 encode a PDF file for transport over XML-RPC in Python?

4条回答
  •  情书的邮戳
    2021-02-04 14:33

    If you don't want to use the xmlrpclib's Binary class, you can just use the .encode() method of strings:

    a = open("pdf_reference.pdf", "rb").read().encode("base64")
    

提交回复
热议问题