检查 Boto3 版本

blu*_*ndr 8 python

如何检查我正在运行的 boto3 版本?

我尝试进入 REPL 并运行以下命令:

>>> import boto3
>>> boto3.Version
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'boto3' has no attribute 'Version'
Run Code Online (Sandbox Code Playgroud)

小智 27

我知道这已经晚了,但您也可以使用:

pip 显示 boto3


小智 10

您始终可以使用 dir 函数来了解对象的所有属性和方法。

dir(boto3)

['DEFAULT_SESSION', 'NullHandler', 'Session', '__author__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__', '_get_default_session', 'client', 'docs', 'exceptions', 'logging', 'resource', 'resources', 'session', 'set_stream_logger', 'setup_default_session', 'utils']
Run Code Online (Sandbox Code Playgroud)

从这个输出中您可以看到__version__

boto3.__version__
Run Code Online (Sandbox Code Playgroud)


BHC*_*BHC 5

尝试使用.__version__.version

PEP 8 标准就是为此使用该__version__属性,但值得注意的是一些模块实现了version