I am running the below code which run fine when I hard code the value
from nsetools import Nse
nse = Nse()
with open('all_nse_stocks') as nse_stocks:
for stock in nse_stocks:
q = nse.get_quote('INFY')
print q.get('open'), '', q.get('lastPrice'), '', q.get('dayHigh'), '', q.get('dayLow')
see that I have hard-coded the value nse.get_quote('INFY')
But when I run the following code, I get the following error:
from nsetools import Nse
nse = Nse()
with open('all_nse_stocks') as nse_stocks:
for stock in nse_stocks:
q = nse.get_quote(stock)
print q.get('open'), '', q.get('lastPrice'), '', q.get('dayHigh'), '', q.get('dayLow')
ERROR:
Traceback (most recent call last):
File "test.py", line 6, in <module>
print q.get('open'), '', q.get('lastPrice'), '', q.get('dayHigh'), '', q.get('dayLow')
AttributeError: 'NoneType' object has no attribute 'get'
Please help
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…