我越来越从JSON响应转储在Python文件,我试图将其加载到一个log.txt
文件,但这并没有打印出任何东西无法写入字典使用json.dumps()
我的功能
def get_customer_last_action_executed(self):
"""
Get the customer last action executed
By inputing the CustomerID
:return:
"""
payload ={'customerID': self.CustomerID}
if not self.CustomerID:
customer_id = raw_input("Please provide the customer ID:")
self.CustomerID = customer_id
# raise Exception('No customerID provided')
response = self.send_request(self.get_customer_last_action_executed_url + self.CustomerID,
json.dumps(payload),
"GET")
print response.url, response.status_code
print response, response.text, response.reason
if response:
print self.sucessful_msg
else:
print self.error_msg
with open('log.txt', 'w') as f:
json.dumps(payload, f)
[编辑]你的问题并显示'def self.send_request(...'。 – stovfl