python - 如何连接到 boto3 中的区域

标签 python boto3

怎样才能实现命令:

boto.ec2.connect_to_region()

使用 boto3 套件?
docs中好像不是一目了然

我想这是一个比您可以在以下 post 中找到的扩展答案更简单和更精确的问题.

谢谢你的帮助

最佳答案

boto3 希望您默认指定区域。因此,在 Python 中为您提供的解决方案是:

>>> import boto3
>>> boto_client = boto3.client('ec2', region_name='us-west-2')

您还可以设置默认区域。为此:
>>> import boto3
>>> boto_client = boto3.setup_default_session(region_name='us-west-2')
>>> boto_client = boto3.client('ec2')

关于python - 如何连接到 boto3 中的区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52167834/

相关文章:

python - wxPython 在 THIThemeTextInfoPublic::GetOptions() const + 9 处随机崩溃

python - 如何使用 LibVLC 更改 MediaListPlayer 中的播放音量?

python-3.x - 从 boto3 table.batch_writer 对象获取 Http 响应

python - 使用 boto3 从 EC2 实例附加/分离安全组

python - boto3:无法使用 list_distributions 找到 CloudFront key

configuration - cloudformation参数文件的ini文件

Linux 上的 Python 模块 win32com

python - 我如何在 python 中对 csv 文件中的数据进行数字排序

python - 类型错误 : 'frozenset' object is not callable; Python2. 7

docker - 有没有办法使用 conda 或通过 tar 文件安装 Boto3?