开发者社区 问答 正文

只打印对象的一部分

使用Python 3.8.0,这段代码

p = get_quote_yahoo("AUPH")
print(p) 

给出结果:

"language region quoteType  ...     market esgPopulated   price
AUPH    en-US     US    EQUITY  ...  us_market        False  19.825
[1 rows x 60 columns]"

这段代码:

print(p.price)

给:

"AUPH    19.8893
 Name: price, dtype: float64"

如何只访问p中的浮点数(19.8893)以便只打印数字? 问题来源StackOverflow 地址:/questions/59380809/printing-only-one-part-of-an-object

展开
收起
kun坤 2019-12-28 14:09:32 432 分享 版权
1 条回答
写回答
取消 提交回答
  • 试试这个:

    print(p.price.values[0])
    
    2019-12-28 14:09:37
    赞同 展开评论
问答分类:
问答地址: