python-3.x - 如何将dict的每个键和值作为参数传递给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)
- 现在我想在调用此函数时将 dict 作为 arg 传递
#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)
有多种方法。你也可以通过整个字典。
推荐阅读
- php - 如何在 Eloquent 的日期时间列的时间上使用聚合函数?
- python - 如何将不带引号的字符串以及带有数组和子字典的字符串转换为python中的字典?
- fancytree - 如何点击选定的 FancyTree 节点再次激活?
- python - pandas autocorr 可以处理不规则的采样时间序列数据吗?
- javascript - 返回值中的传播运算符错误,解析错误
- r - 使用 dplyr 根据列值创建组 (group_by)
- c# - 如何强制 IQueryable 中的方法进行评估?
- encryption - Snowflake 平台上传输中的数据加密
- angular - 您可以在模板中以角度使用扩展运算符吗
- python - 在元类的 __call__ 中获取 __init__ 的可选参数