[英]use boto3 command as a string
我們可以使用boto3
包從mTurk帳戶獲取數據(或在AWS中執行其他任何操作)。 例如:
client = boto3.client('mturk')
balance = client.get_account_balance()
有沒有辦法將boto3命令用作字符串? 就像是:
balance = client.get_command('get_account_balance')
get_command
完全只是出於說明目的。
使用getattr
內置函數:
getattr(client, 'get_account_balance')()
您可以使用內置的getattr
:
def get_command(client, command):
return getattr(client, command)()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.