l = [u'Dav watson', u'Davis']
结果应该是:
[
{
first_name: 'Dav',
last_name: 'Watson'
}, {
firstname:'Davis'
}
]
答案 0 :(得分:5)
import string
l = [u'Dav watson', u'Davis']
[dict(zip(('first_name', 'last_name'), map(string.capitalize, l[0].split()))),
{'firstname': l[1]}]
# returns:
[{'first_name': u'Dav', 'last_name': u'Watson'}, {'firstname': u'Davis'}]