我正在尝试在此地址下返回类似json的对象:
http://ntt.vipserv.org/data/shows
但结果我得到了:
{'1':{'url':u'http://www.rte.ie/tv/crimecall/','image':u'http://img.rasset.ie/0002c8d0-250 .jpg','id':u'2','name':u'Crimecall'}}
如何摆脱unicode字符串?
我的代码:
objects = Show.objects.all()
i = 0
dict = {}
small_dict = {}
for o in objects:
small_dict = {'id': o.id.decode('ascii'), 'url': o.url.decode('ascii'), 'name': o.name.decode('ascii'), 'image': o.image.decode('ascii')}
dict[str(i+1)] = small_dict
small_dict = {}