Parse的快速入门指南使这个Python代码开始使用云代码:
import json,httplib
connection = httplib.HTTPSConnection('api.parse.com', 443)
connection.connect()
connection.request('POST', '/1/functions/hello', json.dumps({
}), {
"X-Parse-Application-Id": "xxxxxxxxxxxx",
"X-Parse-REST-API-Key": "xxxxxxxxxxxxx",
"Content-Type": "application/json"
})
result = json.loads(connection.getresponse().read())
print result
当我运行它时,这段代码给我一个语法错误,现在我对它做了什么。如何更改引号或格式以使其起作用?
答案 0 :(得分:0)
这似乎解决了语法问题:
# -*- coding: utf-8 -*-
import json,httplib
connection = httplib.HTTPSConnection('api.parse.com', 443)
connection.connect()
headers = {'Content-type': 'application/json'}
jdump = {'X-Parse-Application-Id': 'xxxxxxxxxxxxxx', 'X-Parse-REST-API-Key': 'xxxxxxxxxxx', 'Content-Type': 'application/json'}
json_jdumps = json.dumps(jdump)
connection.request('POST', '/1/functions/hello', json_jdumps, headers)
result = json.loads(connection.getresponse().read())
print result