何について:source
はサブリストのリストである
result = {country:pop for country,pop in source}
。
またはシェルで:
>>> source = [['Andorra', '69165'], ['Algeria', '40375954'], ['Antigua and Barbuda', '92738'], ['Azerbaijan', '9868447'], ['Australia', '24309330'], ['Aruba', '104263'], ['Albania', '2903700'], ['American Samoa', '55602'], ['Afghanistan', '33369945'], ['Anguilla', '14763'], ['Austria', '8569633'], ['Armenia', '3026048'], ['Angola', '25830958'], ['Argentina', '43847277']]
>>> {country:pop for country,pop in source}
{'Andorra': '69165', 'Angola': '25830958', 'Austria': '8569633', 'Armenia': '3026048', 'Anguilla': '14763', 'American Samoa': '55602', 'Albania': '2903700', 'Australia': '24309330', 'Afghanistan': '33369945', 'Aruba': '104263', 'Azerbaijan': '9868447', 'Argentina': '43847277', 'Antigua and Barbuda': '92738', 'Algeria': '40375954'}
EDIT
あなたの質問を再読み込みした後、私はあなたが探し思う:
result = [{'country':country,'population':pop} for country,pop in source]
これが与える:
>>> source = [['Andorra', '69165'], ['Algeria', '40375954'], ['Antigua and Barbuda', '92738'], ['Azerbaijan', '9868447'], ['Australia', '24309330'], ['Aruba', '104263'], ['Albania', '2903700'], ['American Samoa', '55602'], ['Afghanistan', '33369945'], ['Anguilla', '14763'], ['Austria', '8569633'], ['Armenia', '3026048'], ['Angola', '25830958'], ['Argentina', '43847277']]
>>> [{'country':country,'population':pop} for country,pop in source]
[{'population': '69165', 'country': 'Andorra'}, {'population': '40375954', 'country': 'Algeria'}, {'population': '92738', 'country': 'Antigua and Barbuda'}, {'population': '9868447', 'country': 'Azerbaijan'}, {'population': '24309330', 'country': 'Australia'}, {'population': '104263', 'country': 'Aruba'}, {'population': '2903700', 'country': 'Albania'}, {'population': '55602', 'country': 'American Samoa'}, {'population': '33369945', 'country': 'Afghanistan'}, {'population': '14763', 'country': 'Anguilla'}, {'population': '8569633', 'country': 'Austria'}, {'population': '3026048', 'country': 'Armenia'}, {'population': '25830958', 'country': 'Angola'}, {'population': '43847277', 'country': 'Argentina'}]
あなたが望む正確な出力を表示してください。 –
また、あなたが行った研究とあなたが試したことを示してください。 –
@PHPLoverあなたの質問は役に立たなかったので、編集をロールバックしました。 –