2017-01-30 63 views

回答

0

該方法返回基於64位編碼的二進制數據,您需要做的是解碼二進制數據。

請參閱關於enconde和解碼二進制數據的文章。所以你需要與該對象在這裏使用Python客戶端和Python 3

#!/usr/bin/env python 

import SoftLayer 
import xmlrpc.client 
import base64 
import os 

USERNAME = 'set me' 
API_KEY = 'set me' 

quoteId = 1560845 

client = SoftLayer.Client(username=USERNAME, api_key=API_KEY) 

accountClient = client['SoftLayer_Billing_Order_Quote'] 
binaryData = accountClient.getPdf(id=quoteId) 
decodeBinary = binaryData.data 
file = open('test.pdf','wb') 
file.write(decodeBinary) 

問候爲例工作

https://code.tutsplus.com/tutorials/base64-encoding-and-decoding-using-python--cms-25588

Python客戶端返回xmlrpc.client.Binary對象

-1

這是我對我的問題的回答。

# import 
import SoftLayer 
import sys 
parm=sys.argv 
quoteId=parm[1] 

# account info 
client = SoftLayer.create_client_from_env() 

# getPdf as a binary data 
getPdf = client['Billing_Order_Quote'].getPdf(id=quoteId) 

# Save as a PDF 
quoteFileName = "Quote_ID_%s.pdf" % quoteId 
w = open(quoteFileName, "wb") 
w.write(getPdf.data) 
w.close() 
+0

這實際上是我之前給你相同的代碼,而你沒有記住我的答案是正確的:S @#$#$$%%! –

相關問題