我正在尝试使用https://github.com/Nasdaq/DataOnDemand中的NASDAQ API,但似乎无法在Python 3中使用它。
我修复了urllib的东西,并在第92行遇到错误,我通过将其编码为utf-8来修复
Before:
request_parameters = urllib.parse.urlencode(values)
Fix:
request_parameters = urllib.parse.urlencode(values).encode('utf-8')
但现在我收到了错误:
response = urllib.request.urlopen(req)
>>>TypeError: cannot use a string pattern on a bytes-like object
当我尝试解码时,我得到:
response = urllib.request.urlopen(req).decode()
OR
response = urllib.request.urlopen(req).decode('utf-8')
>>>AttributeError: 'HTTPResponse' object has no attribute 'decode'
这就是我的导入:
import urllib.request
import urllib.parse
import xml.etree.cElementTree as ElementTree
import re
from pprint import pprint
import matplotlib.dates as mdates
import matplotlib.pyplot as plt
import datetime as dt
感谢任何帮助