gpt4 book ai didi

Python调用服务接口的实例

转载 作者:qq735679552 更新时间:2022-09-28 22:32:09 24 4
gpt4 key购买 nike

CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.

这篇CFSDN的博客文章Python调用服务接口的实例由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.

如下所示:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#! /usr/bin/env python
# coding=utf-8
######################################################################
# Author: yini.xie
# Create Time: 2016-07-05 16:28:42
# Descriptioin:
######################################################################
import os
import sys
import time
import json
import urllib
import urllib2
from urllib import quote
from datetime import datetime
 
pathATM = "http://192.168.217.217:4080/invoke.json"
 
def fmtLen(value, length = 7 ):
   fmt = '{0:>%d}' % (length)
   return fmt. format (value)
 
 
def changeWithdrawRule(customerId, productCode, ruleTemplateId, ruleId, operator):
   service_url_s = "http://service.xxx.com/tsService/TSRuleService_1.0.0"
   method_s = "bindCustomerWithdrawRuleTemplate"
   params_s = "parameters[]=%d&parameters[]=%d&parameters[]=%d&parameters[]=%d&parameters[]=%s" % (customerId, productCode, ruleTemplateId, ruleId, operator)
   params_s + = "&url=%s&method=%s&parameterTypes[]=int&parameterTypes[]=int&parameterTypes[]=int&parameterTypes[]=int&parameterTypes[]=java.lang.String" % (service_url_s, method_s)
   url_s = pathATM + "?" + quote(params_s, safe = '&=' )
   data_s = urllib2.urlopen(url_s).read()
   print url_s
   return json.loads(data_s)
 
if __name__ = = '__main__' :
   start = datetime.now()
 
   for line in open (sys.argv[ 1 ]).xreadlines():
     fields = line.strip().split()
     customerId = int (fields[ 0 ])
     productCode = int (fields[ 1 ])
     ruleTemplateId = int (fields[ 2 ])
     ruleId = int (fields[ 3 ])
     print "start to deal customerId = " + str (customerId)
    
     changeWithdrawRule(customerId, productCode, ruleTemplateId, ruleId, "Case" )
  
 
   end = datetime.now()

运行Python脚本,即可调用相应的接口修改数据库数据.

?
1
python ChangeCustomerRule.py text.txt

text.txt中即为参数,以空格分隔 。

以上这篇Python调用服务接口的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持我.

原文链接:https://blog.csdn.net/umgsai/article/details/54288422 。

最后此篇关于Python调用服务接口的实例的文章就讲到这里了,如果你想了解更多关于Python调用服务接口的实例的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com