简体   繁体   中英

Python yahoo_finance package, get_info() not working

I use Python 3.5.2 from anaconda distribution, yahoo-finance 1.3.2 (latest) version. The problem is the function get_info() only returns 'symbol', but in the description of this package, it should return other things, too, like 'start'. My main aim is to get 'start' value.

https://pypi.python.org/pypi/yahoo-finance/1.3.2

The codes are:

from yahoo_finance import Share
yahoo = Share('YHOO')
yahoo.get_info()

My result is:

{'symbol': 'YHOO'}

The results by the description of the package website is:

{u'FullTimeEmployees': u'12200',
 u'Industry': u'Internet Information Providers',
 u'Sector': u'Technology',
 u'end': u'2014-05-03',
 u'start': u'1996-04-12',
 u'symbol': u'YHOO'}

Does anyone know why? And how can I get the value of 'start'? Thanks!

It looks like returned data is in Jason/dictionary format. See examples in the link you provided, you need to import and use pprint (pretty print) to see all what is returned to you:

from pprint import pprint
pprint(yahoo.get_info()) 

If you don't have it yet, you will need to install it first:

pip install pprint

Then you need to use key:value (like in every dictionary) to narrow down to the part of the info you are looking for.

The returned data is nested, which you will easy see with pprint. What you got is dictionary's first key:value, but data you want is inside, nested key:value

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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