JSON字典以随机顺序打印到屏幕

时间:2015-01-05 13:45:59

标签: python json

我在源代码中创建了一个看起来像这样的JSON对象:

 {"34693":"Marko Arnautovic","23122":"Asmir Begovic","39935":"Steven N'Zonzi","4145":"Robert 
Huth","3860":"Jonathan Walters","8505":"Glenn Whelan","23446":"Marc Wilson","29762":"Oussama 
Assaidi","24148":"Erik Pieters","26013":"Mame Biram Diouf","75177":"Marc Muniesa","38772":"Geoff 
Cameron","29798":"Ryan Shawcross","107395":"Jack Butland","3807":"Peter Crouch","8327":"Charlie 
Adam","18181":"Phil Bardsley","254558":"Oliver Shenton","130334":"Adnan 
Januzaj","4092":"Rafael","18701":"Falcao","10620":"Anders Lindegaard","4564":"Robin van 
Persie","25363":"Juan Mata","71174":"Ander Herrera","79554":"David de Gea","71345":"Chris 
Smalling","81726":"Phil Jones","118244":"Luke Shaw","137795":"Tyler Blackett","145271":"James 
Wilson","2115":"Michael Carrick","3859":"Wayne Rooney","8166":"Ashley Young","5835":"Darren
 Fletcher","22079":"Jonny Evans"}

但是,当我将其打印到屏幕上时,我明白了:

 {u'71174': u'Ander Herrera', u'18701': u'Falcao', u'8505': u'Glenn Whelan', u'118244': u'Luke 
Shaw', u'254558': u'Oliver Shenton', u'34693': u'Marko Arnautovic', u'3807': u'Peter Crouch', 
u'3860': u'Jonathan Walters', u'23122': u'Asmir Begovic', u'75177': u'Marc Muniesa', u'38772': 
u'Geoff Cameron', u'39935': u"Steven N'Zonzi", u'8327': u'Charlie Adam', u'23446': u'Marc Wilson', 
u'81726': u'Phil Jones', u'4145': u'Robert Huth', u'24148': u'Erik Pieters', u'26013': u'Mame Biram Diouf', u'10620': u'Anders Lindegaard', u'71345': u'Chris Smalling', u'2115': u'Michael Carrick', 
u'107395': u'Jack Butland', u'4092': u'Rafael', u'8166': u'Ashley Young', u'18181': u'Phil Bardsley',
 u'145271': u'James Wilson', u'4564': u'Robin van Persie', u'130334': u'Adnan Januzaj', u'25363': 
u'Juan Mata', u'5835': u'Darren Fletcher', u'3859': u'Wayne Rooney', u'79554': u'David de Gea', 
u'29798': u'Ryan Shawcross', u'29762': u'Oussama Assaidi', u'137795': u'Tyler Blackett', u'22079': 
u'Jonny Evans'}

前几个条目看起来像是按照名字的升序按字母顺序排序,但顺序似乎完全解体了。

任何人都可以告诉我:

1)为什么会这样? 2)我需要以原始顺序打印到屏幕的语法是什么?

在这个例子中,如果JSON对象混乱,那么问题并不是太大,但是我正在解析其他更大的项目,其中以随机顺序打印到屏幕使得无法跟进。

由于

0 个答案:

没有答案