求解决:
import tushare as ts
import pandas as pd
import datetime
f=open('D:\stock.txt')
time1=datetime.datetime.now()
stocks=[line.strip() for line in f.readlines()]
data1=ts.get_realtime_quotes(stocks[0:880])
data2=ts.get_realtime_quotes(stocks[880:1760])
data3=ts.get_realtime_quotes(stocks[1760:2640])
data4=ts.get_realtime_quotes(stocks[2640:-1])
time2=datetime.datetime.now()
print('开始时间:'+str(time1))
print('结束时间:'+str(time2))
print(data1)
print(data2)
print(data3)
print(data4)
报错:
Traceback (most recent call last):
File "C:\Users\bestg\Desktop\get_realtime_quotes.py", line 7, in <module>
data1=ts.get_realtime_quotes(stocks[0:880])
File "F:\pythonThree\lib\site-packages\tushare\stock\trading.py", line 371, in get_realtime_quotes
text = urlopen(request,timeout=10).read()
File "F:\pythonThree\lib\urllib\request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "F:\pythonThree\lib\urllib\request.py", line 532, in open
resp**e = meth(req, resp**e)
File "F:\pythonThree\lib\urllib\request.py", line 642, in http_resp**e
'http', request, resp**e, code, msg, hdrs)
File "F:\pythonThree\lib\urllib\request.py", line 570, in error
return self._call_chain(*args)
File "F:\pythonThree\lib\urllib\request.py", line 504, in _call_chain
result = func(*args)
File "F:\pythonThree\lib\urllib\request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 400: Bad Request
|