简体   繁体   English

从Boto3的集合中获取可用的方法

[英]Get available methods from collection in boto3

This might be a very silly question, but I couldn't find any help in the official documentation and nothing when I was trying to google it... I'm working with boto3 and I'm using collections to get information about ec2 instances. 这可能是一个很愚蠢的问题,但是我在官方文档中找不到任何帮助,而在尝试搜索它时却一无所有...我正在使用boto3,并且正在使用集合来获取有关ec2实例的信息。 Examples I managed to find use a few methods to print instance id and type... 我设法找到的示例使用了一些方法来打印实例ID和类型...

ec2 = boto3.resource('ec2')
instances = ec2.instances.filter(
    Filters=[{'Name': 'instance-state-name', 'Values': ['running']}])
for instance in instances:
    print(instance.id, instance.instance_type, instance.tags)

My problem is I cannot find any reference in the documentation what other methods I can call, so I know there is instance.id and instance.instance_type but to find instance.tag I had to run something like this 我的问题是我在文档中找不到我可以调用的其他方法的任何引用,因此我知道有instance.idinstance.instance_type但是要找到instance.tag我必须运行类似的方法

    ec2 = boto3.resource('ec2')
instances = ec2.instances.filter(
    Filters=[{'Name': 'instance-state-name', 'Values': ['running']}])
for instance in instances:
    print(dir(instance))

This way I managed to get all available methods, but this seems to be very strange way of getting that information? 这样我设法获得了所有可用的方法,但这似乎是获取信息的一种非常奇怪的方法? I'm relatively new to python, so maybe I'm reading documentation incorrectly, or something? 我是python的新手,所以也许我在阅读文档不正确,或者是什么? can someone please help? 有人可以帮忙吗? :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM