使用boto3命令作为字符串

我们可以使用boto3包从mTurk帐户获取数据(或在AWS中执行其他任何操作)。例如:


client = boto3.client('mturk')

balance = client.get_account_balance()

有没有办法将boto3命令用作字符串?就像是:


balance = client.get_command('get_account_balance')

get_command 当然,此处完全出于说明目的。


MYYA
浏览 120回答 2
2回答

叮当猫咪

使用getattr内置功能:getattr(client, 'get_account_balance')()
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python