将python pandas列表的每个值作为参数插入REST-API GET方法字符串中

问题描述

我想将列表的每个值作为参数插入REST-API GET方法字符串中。

首先,我在“ ABC”列中读取了一个excel文件。有4000多个包含字符串的行,必须将它们连续插入RestAPI服务器的GET语句中。 我可以打印该列表的每个字符串,如下面的代码代码1)所示:但是,如果我想将该列表的每个字符串值作为参数插入GET-Statement中,该怎么做?参数必须一个一个调用,即依次调用。我尝试了以下代码(code2),但它不起作用。有什么想法吗?

代码1:

get_all_ABC = pd.read_excel('C:/Users/xxx/xxx/ABC.xlsx',skiprows=1,usecols="A").set_index('ABC')
listABC = get_all_ABC.index.tolist()
for i in listABC:
   print(i)

code2:

get_all_ABC = pd.read_excel('C:/Users/xxx/xxx/ABC.xlsx',usecols="A").set_index('ABC')
listABC = get_all_ABC.index.tolist()
for i in listABC:
   url = "http://192.168.xxx.xxx:xxxx/api/xxx/data?ABC=%s" %i
payload = {}
headers= {}
response = requests.request("GET",url,headers=headers,data = payload)
print(response.text.encode('utf8'))

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)