如何将 dict 的每个键和值作为参数传递给 python 中的其他函数

how to pass every key and value of dict as arguments to other function in python

def set_detail_to_user(id, key, val):
    """
    Set details to id@domain by admin
    """

    tx = iroha.transaction([iroha.command('SetAccountDetail',
                account_id=id +'@' + domain_name, key=key, value=val)
            ])
    IrohaCrypto.sign_transaction(tx, ADMIN_PRIVATE_KEY)
    send_transaction_and_print_status(tx)
#now when i call the function
user = new.__id.replace('-', '')
my_dict = new.__dict__
set_detail_to_user(user,every_key_in_my_dict, every_value_in_my_dict)

任何建议请为每个键值对多次调用该函数

for key, value in dict.items():
        set_detail_to_user(id, key, value)

有多种方法。你也可以传递整个字典。