What is the best way to convert a pdf file into base64Binary?
使用python,我要
我的逻辑(不是python)正在将文件的内容读取到字节数组中,然后使用类似
1 2 | byte[] pdfBytes = File.ReadAllBytes(pdfPath); string pdfBase64 = Convert.ToBase64String(pdfBytes); |
请让我知道python中
如此简单
1 2 3 4 | import base64 with open("book.pdf","rb") as pdf_file: encoded_string = base64.b64encode(pdf_file.read()) |
来源:使用base64编码图像文件