【发布时间】:2017-12-31 06:53:05
【问题描述】:
我收到来自 JSON 转储的响应,我正在尝试将其加载到 log.txt 文件中,但这不会打印出任何内容
我的功能
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)
【问题讨论】:
-
Edit 你的问题并显示
def self.send_request(...。