使用python3.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
),以便只打印数字?你知道吗
假设您有以下字符串:
如果您使用
split
方法,您将拥有:因此,对于您的情况,您可以通过执行以下操作获得号码:
试试这个:
因为
p.price
是Series object,所以可以使用所有可用的方法。你知道吗这是获取值的正确方法
或者
或者
输出
相关问题 更多 >
编程相关推荐