gpt4 book ai didi

python - Python 变量的循环列表

转载 作者:太空宇宙 更新时间:2023-11-03 20:12:49 26 4
gpt4 key购买 nike

我正在尝试循环遍历列表并将“extensionid”插入 URL

extensionid = ['1234','12356']
url = '/restapi/v1.0/account/~/extension/'+extensionid+'/presence'

params = {

'dndStatus': "TakeAllCalls",

}

resp = platform.get(url, params,)
print ((resp.text()))

但我收到错误

url = '/restapi/v1.0/account/~/extension/'+extensionid+'/presence' TypeError: can only concatenate str (not "list") to str [Finished in 1.121s

我做错了什么?

谢谢!

最佳答案

你可能需要。

extensionid = ['1234','12356']
url = '/restapi/v1.0/account/~/extension/{}/presence'

params = {
'dndStatus': "TakeAllCalls",
}

for id in extensionid: #iterate each id
resp = platform.get(url.format(id), params) #form URL and query.
print ((resp.text()))

关于python - Python 变量的循环列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58623455/

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