问题exactly_one
在于g.geocode
. 当我在 shell 中运行它时,我得到:
>>> g.geocode('6943, Australia', exactly_one=False)
[(u'Australia 6943, Villafontana, Tijuana Municipality, Baja California, Mexico',
(32.4988788, -116.8620506)),
(u'Australia 6943, Castelar, Buenos Aires Province, Argentina',
(-34.7036339, -58.6423071)),
(u'Australia 6943, Rosario, Santa Fe Province, Argentina',
(-32.9913482, -60.6398934)),
(u'Australia, Lebanon', (33.8879118, 35.4749439)),
(u'Australia, Juliaca, Peru', (-15.4897806, -70.146677)),
(u'Australia, Lima District 15007, Peru', (-12.0397296, -76.9944836)),
(u'Australia, Manila, Philippines', (14.48538, 121.0394822)),
(u'Australia, Conchal\xed, Santiago Metropolitan Region, Chile',
(-33.3929606, -70.6780826)),
(u'Australia, Chiguayante, Biob\xedo Region, Chile',
(-36.9556346, -73.0145556)),
(u'Australia, Copiap\xf3, Atacama Region, Chile', (-27.3978776, -70.2934656))]
现在,您正试图将这个大列表分解为 just place, (lat, lng)
,而实际上它是那些列表;too many values
该列表中只有to unpack
两个(place
和(lat, lng)
),因为实际上有10个。你可以做类似的事情
for place, (lat, lng) in g.geocode(a, exactly_one=False):
print place, lat, lng
或做一些其他类型的列表操作或其他。