我想循环发布csv中的数据请求。
csv文件(有2列(=
agentLicenseID(x) licenseExpirationDate(y)
271844 6/20/2021
271847 6/30/2021
271848 5/21/2021
body = {'sid':API_SID,'key':API_KEY, 'agentLicenseID':x,'licenseExpirationDate':y }
response = requests.post(url=UPD_URL,data=body)
我打算循环csv文件中不同x和y值(agentLicenseID和licenseExpirationDate(的响应
借助pandas
:
import pandas as pd
df = pd.read_csv("your_file.csv", sep=r"s+") # <-- change the separator if it's different
for x, y in zip(df["agentLicenseID"], df["licenseExpirationDate"]):
body = {
"sid": API_SID,
"key": API_KEY,
"agentLicenseID": x,
"licenseExpirationDate": y,
}
response = requests.post(url=UPD_URL, data=body)
# ...