我尝试在迭代中运行以下代码,从名为sample.csv的CSV文件中提取VAR1和VAR2,并将它们插入下面的匹配点,然后对CSV文件中的每一行循环该函数。
import http.client
import json
conn = http.client.HTTPSConnection("a.b.com")
payload = json.dumps({
"node_list": [
{
"id": VAR1,
"with_descendants": True
}
]
})
headers = {
'Content-Type': 'application/json',
'Cookie': 'A'
}
conn.request("PUT", "/poweruser/v1/powerusers/VAR2/branches?access_token=xyz", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Sample.csv:
变量1、变量2 10,20 30,40 50,60 70,80
1条答案
按热度按时间t1qtbnec1#
你可以使用
csv
模块来解析这些行。用您的代码替换print语句。