获取list指定参数的索引
datas[4]={'clientName': 'fei fei2', 'accountInfoList': [{'accountId': '5003991110', 'accountCategory': 'EQUITIES', 'accountCategoryDesc': '证券', 'accountCategoryCode': 'securitiesCash', 'accountCategoryAlias': '香港及环球证券账户(现金)'}, {'accountId': '5003991210', 'accountCategory': 'EQUITIES', 'accountCategoryDesc': '证券', 'accountCategoryCode': 'securitiesMargin', 'accountCategoryAlias': '香港及环球证券账户(保证金)'}, {'accountId': '5003993210', 'accountCategory': 'FUTURES', 'accountCategoryDesc': '期货', 'accountCategoryCode': 'futuresMargin', 'accountCategoryAlias': '香港及环球期货账户(保证金)'}, {'accountId': '500399321M', 'accountCategory': 'FUTURES', 'accountCategoryDesc': '期货', 'accountCategoryCode': 'futuresDayTradeMargin', 'accountCategoryAlias': '香港期货即日买卖账户(保证金)'}, {'accountId': '5003995216', 'accountCategory': 'FOREX', 'accountCategoryDesc': '外汇', 'accountCategoryCode': 'leveragedForeignExchangeAccountMargin', 'accountCategoryAlias': '杠杆式外汇账户(保证金)'}], 'remittanceBankList': [{'clientBankAccountId': '1321', 'remittanceBankName': '中国银行(香港)有限公司 012', 'remittanceBankCard': '4567890', 'sibMobile': None, 'remittanceBankCode': '012', 'bankAccountName': None, 'eddaBankAccountName': None}, {'clientBankAccountId': '1322', 'remittanceBankName': '香港上海汇丰银行有限公司 004', 'remittanceBankCard': '234567890', 'sibMobile': None, 'remittanceBankCode': '004', 'bankAccountName': None, 'eddaBankAccountName': None}, {'clientBankAccountId': '1323', 'remittanceBankName': '渣打银行(香港)有限公司 003', 'remittanceBankCard': '123456789', 'sibMobile': None, 'remittanceBankCode': '003', 'bankAccountName': None, 'eddaBankAccountName': None}, {'clientBankAccountId': '1325', 'remittanceBankName': '中信银行(国际)有限公司 018', 'remittanceBankCard': '456778888', 'sibMobile': None, 'remittanceBankCode': '018', 'bankAccountName': None, 'eddaBankAccountName': None}], 'beneficiaryBankList': [], 'serviceCharges': {'USD': '45', 'CNY': '0', 'HKD': '350'}}
根据accountId 找到对应的accountCategoryCode
idx = next((i for i, d in enumerate(datas[4]['accountInfoList']) if accountId in d['accountId']), None) # 根据账号所在索引找到对应的账户类型索引
accountCategoryCode = datas[4]['accountInfoList'][idx]['accountCategoryCode'] # 账户类型