2
私はここに小さな問題があります。だから、よく知られているREST APIの呼び出しをいくつか書いています。私はすべての応答をリストとして表示したいという事実を除いて、すべてうまくいっています(私が操作する方が良い)。私は(スプリットを使用するために使用されていますPython:リストとして表示する際の問題httplib.HTTPMessage
import sys, httplib
HOST = "api.sugarsync.com"
API_URL = "https://api.sugarsync.com"
def do_request(xml_location):
request = open(xml_location,"r").read()
webservice = httplib.HTTPS(HOST)
webservice.putrequest("POST", "authorization", API_URL)
webservice.putheader("Host", HOST)
webservice.putheader("User-Agent","Python post")
webservice.putheader("Content-type", "application/xml")
webservice.putheader("Content-type", "application/xml")
webservice.putheader("Accept", "*/*")
webservice.putheader("Content-length", "%d" % len(request))
webservice.endheaders()
webservice.send(request)
statuscode, statusmessage, header = webservice.getreply()
result = webservice.getfile().read()
return statuscode, statusmessage, header
return result
do_request('C://Users/my_user/Documents/auth.xml')
)が、この場合には、結果がこれです::My機能はこれです
[201, 'Created', <httplib.HTTPMessage instance at 0x0000000001F68AC8>]
まあ、私は第三の目的(httplib.HTTPMessageインスタンスでも必要0x0000000001F68AC8>)をリストとして表示し、その中のいくつかのデータを抽出します。
ありがとうございます!