0
l = [u'Dav watson', u'Davis']
的結果應該是:我該怎麼做?
[
{
first_name: 'Dav',
last_name: 'Watson'
}, {
firstname:'Davis'
}
]
l = [u'Dav watson', u'Davis']
的結果應該是:我該怎麼做?
[
{
first_name: 'Dav',
last_name: 'Watson'
}, {
firstname:'Davis'
}
]
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'}]
你有沒有嘗試尚未解決這對你自己的? – 2011-04-06 12:10:38
你應該至少試圖寫出一個好的標題。 – 2011-04-06 12:14:04