【发布时间】:2021-09-01 14:53:22
【问题描述】:
我试图根据字典的键设置值,同时创建字典本身。
我可以通过一个额外的步骤来做到这一点,但有没有办法做到以下几点:
dictionary = {
'a': 'Key of this = ' + dictionary.key(),
'b': 'Key of this = ' + dictionary.key(),
'c': 'Key of this = ' + dictionary.key(),
}
预期的结果是:
>>>dictionary
{
'a': 'Key of this = a',
'b': 'Key of this = b',
'c': 'Key of this = c',
}
【问题讨论】:
标签: python dictionary key