import json
json_data = json.loads(prev.getResponseDataAsString())
# Extract the currentAccountList from the JSON data
currentAccountList = json_data.get("data", {}).get("currentAccountList", [])
disbursementAccounts = json_data.get("data", {}).get("disbursementAccounts", [])
# Initialize an empty list to store account IDs where currency is KES
KES_B002_accounts = []
KES_B003_accounts = []
USD_B002_accounts = []
EUR_B002_accounts = []
CNY_B002_accounts = []
GBP_B002_accounts = []
# Iterate through each account in the current account list
for account in currentAccountList:
if account.get("currency") == "KES":
KES_B002_accounts.append(account.get("accountId"))
if account.get("currency") == "USD":
USD_B002_accounts.append(account.get("accountId"))
if account.get("currency") == "EUR":
EUR_B002_accounts.append(account.get("accountId"))
if account.get("currency") == "CNY":
CNY_B002_accounts.append(account.get("accountId"))
if account.get("currency") == "GBP":
GBP_B002_accounts.append(account.get("accountId"))
for account in disbursementAccounts:
if account.get("currency") == "KES":
KES_B003_accounts.append(account.get("accountId"))
使用动态变量名承接实参
names = locals()
for index, account in enumerate(KES_B002_accounts):
names['KES_B002_accounts_%s' % index]=account
log.info('KES_B002_accounts_'+str(index)+':'+account)
vars.put("KES_B002_accounts_"+str(index), account)
for index, account in enumerate(KES_B003_accounts):
names['KES_B003_accounts_%s' % index]=account
log.info('KES_B003_accounts_'+str(index)+':'+account)
vars.put("KES_B003_accounts_"+str(index), account)
for index, account in enumerate(USD_B002_accounts):
names['USD_B002_accounts_%s' % index]=account
log.info('USD_B002_accounts_'+str(index)+':'+account)
vars.put("USD_B002_accounts_"+str(index), account)
for index, account in enumerate(EUR_B002_accounts):
names['EUR_B002_accounts_%s' % index]=account
log.info('EUR_B002_accounts_'+str(index)+':'+account)
vars.put("EUR_B002_accounts_"+str(index), account)
for index, account in enumerate(CNY_B002_accounts):
names['CNY_B002_accounts_%s' % index]=account
log.info('CNY_B002_accounts_'+str(index)+':'+account)
vars.put("CNY_B002_accounts_"+str(index), account)文章来源:https://www.toymoban.com/news/detail-814147.html
for index, account in enumerate(GBP_B002_accounts):
names['GBP_B002_accounts_%s' % index]=account
log.info('GBP_B002_accounts_'+str(index)+':'+account)
vars.put("GBP_B002_accounts_"+str(index), account)文章来源地址https://www.toymoban.com/news/detail-814147.html
到了这里,关于使用动态变量名承接实参的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!