0
回答
Python 2.x版本 GET / POST reuquest /response 问题
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   
import json

json_input = '{"Brand-SWT": [{"userId": "Brian", "Currency": "CNY"}, {"userId": "David", "Currency": "USD"} ] }'

try:
    decoded = json.loads(json_input)
    for x in decoded['Brand-SWT']:
        print x['userId']
        print x['Currency']
except (ValueError,KeywordError,TypeError):
    print"json format error"

目前自己大概写了这些,但是如果json_input为 response 结果。。。

那代码怎么 改呢? import request      ,  json_input = request.get (????)  

条件
api :http://websitelinke.com/v2/brands/EWT/users/113/credit

heard : 

-H "Content-Type:application/json" \
-H "Authorization: secKey" \

method : get / post (随意~)

request data : { "currencyId": "CNY", "amount": 1160.50, "requestId": "20170403001", "description": null }

response data : 

{"transactionId":12288952,"currencyId":"USD","balance":1553367.02,"updatedTime":"2017-04-04T06:11:04Z"}

环境 : CentOS 7

<无标签>
举报
luxury515
发帖于8个月前 0回/65阅
顶部