【发布时间】:2018-02-13 12:59:03
【问题描述】:
我想创建如下符号列表:
output = ['A','AA','AABA'...'ZYNE']
当前输出为
[
{u'name': u'Agilent Technologies Inc.',
u'symbol': u'A',
u'iexId': u'2',
u'date': u'2018-02-12',
u'type': u'cs',
u'isEnabled': True},
{u'name': u'Alcoa Corporation',
u'symbol': u'AA',
u'iexId': u'12042',
u'date': u'2018-02-12',
u'type': u'cs',
u'isEnabled': True},
{u'name': u'Altaba Inc.',
u'symbol': u'AABA',
u'iexId': u'7653',
u'date': u'2018-02-12',
u'type': u'cs',
u'isEnabled': True},
我想消除 unicode,只从当前列表中提取符号。
我的代码如下
import urllib, json
url = "https://api.iextrading.com/1.0/ref-data/symbols"
response = urllib.urlopen(url)
data = json.loads(response.read())
我只设法得到一个输出为data[0]["symbol"],它返回'u'A',但不在我想要的完整列表中
【问题讨论】:
-
我建议切换到 Python 3。
-
@bkollection JSON 字符串是 Unicode。你希望通过假装得到什么?