python post請求資料案例

來源:互聯網
上載者:User

標籤:odi   edit   and   請求   erro   header   ast   val   running   

#!/usr/bin/python
#coding:utf-8
import requests
import sys
import urllib
import json
import chardet
TARGET_HOST = sys.argv[1]
url = [‘http://‘,TARGET_HOST,‘:30003‘,‘/app-wanda-credit-ds/inner/service/dataService/testfetch‘]
url_name = ‘‘.join(url)

payload = {
"id": "ds_mas_cardAuth",
"params_in": [
{
"byLast": "false",
"id": "name",
"value": "於六二"
},
{
"byLast": "false",
"id": "cardNo",
"value": "330421197709281519"
}
,
{
"byLast": "false",
"id": "cardId",
"value": "6217993300067121225"
},
{
"byLast": "false",
"id": "phone",
"value": "13606833183"
}
],
"refProdCode": "P_C_B142"
}
data = json.dumps(payload)
headers = {
‘content-type‘: "application/json",
‘cache-control‘: "no-cache",
‘postman-token‘: "7902aabc-c83a-1ccb-3f45-a8bcce131cd5"
}

response = requests.request("POST", url_name, data=data, headers=headers)
#print(response.text)
result = json.loads(response.text)
status_num = result["rettag"]["status"].encode(‘utf-8‘)
retstatus = result["retstatus"].encode(‘utf-8‘)
if status_num == "000000" and retstatus == "STATUS_SUCCESS":
print " status is %s ds is running"%status_num
else:
print "status is %s ERROR!!!!!!!!!!!"%status_num

python post請求資料案例

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.