gpt4 book ai didi

python - 如何在 Python 中获取 的值

转载 作者:太空宇宙 更新时间:2023-11-03 15:12:09 26 4
gpt4 key购买 nike

我是 Python 的新手,在 Windows 上使用 Python 2.7 我正在使用 Astropy 库,但是当我想查看以下类的属性时:

>>> astropy.cosmology.FlatLambdaCDM.Ok0

它返回:

<property object at 0x7fa2c7e206d8>

该对象的其他属性也是如此。如何访问数值?

最佳答案

我自己对 astropy 一无所知,但从你的描述来看,Ok0FlatLambdaCDM 类的属性。您通常不应该尝试直接访问类的属性,而是通过类的实例。

尝试这样的事情:

# create an instance
instance = FlatLambdaCDM() # the constructor may require some arguments

# access the property on the instance
instance.Ok0

我不知道 FlatLambdaCDM 类构造函数需要什么参数(如果有的话),因此您可能需要添加更多内容才能获得可用的对象。

关于python - 如何在 Python 中获取 <property object at 0x...> 的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25130331/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com