我有一个长度为14的项目列表:
html_doc = [u'Crabtree Conservation Area - Number 28',
u'Conservation Area',
u'Environment Agency Flood Risk Zone 3',
u'Flood Risk Zone 3',
u'Environment Agency Flood Risk Zone 2',
u'Flood Risk Zone 2',
u'Buildings Structures And Works Exceeding 90 Metres',
u'Aerodrome Safeguarding London Heathrow 1',
u'Controlled Parking Zone T',
u'Controlled Parking Zone T',
u'Flood Zone 3 Low Residual Risk',
u'Flood Zone 3 Low Residual Risk',
u"Embankment Residents' Association",
u"Embankment Residents' Assoc."]数组中的每个元素都应该成对出现"Name":"Constraint_type“,这意味着列表中的第一个和第二个元素是相关的。
我有这个代码,我认为它不会起作用:
for i in xrange(len(html_doc)):
dict.append("Name:" html_doc[i], "Constraint_Type": html_doc[i+1])对此有什么想法吗?
发布于 2015-04-01 05:21:09
html_dict = dict(zip(html_doc[::2], html_doc[1::2]))https://stackoverflow.com/questions/29378728
复制相似问题