UnicodeDecodeError:' utf-8'编解码器不能解码位置18140中的字节0xfc:无效的起始字节

时间:2017-12-10 09:55:19

标签: python encoding utf-8

我正在尝试使用python3从Google财经下载股票数据(请参阅下面的代码)。 我收到编码错误(请参阅下文)。 因为我一周以来一直在使用python,所以我很感激在调试这个方面有所帮助。我已阅读有关此错误的类似帖子,但遗憾的是我无法使用答案(使用不同的代码/库/方案......)

[错误]

>>> stock_prices = DataReader(ticker, data_source, start, end)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/pandas_datareader/data.py", line 
137, in DataReader
session=session).read()
File "/usr/local/lib/python3.6/site-packages/pandas_datareader/base.py", line 
181, in read
params=self._get_params(self.symbols))
File "/usr/local/lib/python3.6/site-packages/pandas_datareader/base.py", line 
79, in _read_one_data
out = self._read_url_as_StringIO(url, params=params)
File "/usr/local/lib/python3.6/site-packages/pandas_datareader/base.py", line 
98, in _read_url_as_StringIO
out.write(bytes_to_str(text))
File "/usr/local/lib/python3.6/site-packages/pandas/compat/__init__.py", line 
74, in bytes_to_str
return b.decode(encoding or 'utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfc in position 18176: 
invalid start byte

[代码]:

from pandas_datareader import DataReader
from datetime import date
start = date(2016,1,1)
end = date(2016,12,31)
ticker = 'AAPL'
data_source = 'google'
stock_prices = DataReader(ticker, data_source, start, end)

0 个答案:

没有答案