小编Ste*_*ncé的帖子

创建字典时:TypeError: unhashable type: 'dict'

我正在尝试编写一个Character Generator可以用于笔和纸角色扮演游戏的简单脚本。我正在考虑将所有信息存储在嵌套字典中并将其保存到 JSON 文件中。

但是,在创建以下字典时,我收到错误:

nhashable type: 'dict', focussing on {'cha': 1}}}
Run Code Online (Sandbox Code Playgroud)
core_phb = {
'races': {
    'Human': {
        {'abilities': 'None'},
        {'alignment': 'Neutral'},
        {'size': 'Medium'},
        {'speed': 6},
        {'languages': 'Common'},
        {'ability_modifiers': {
            {'str': 1},
            {'dex': 1},
            {'con': 1},
            {'int': 1},
            {'wis': 1},
            {'cha': 1}}}
    },
    'Dwarf': {
        {'abilities': [
            'ability1',
            'ability2'
            ]},
        {'alignment': 'Lawful Good'},
        {'size': 'Medium'},
        {'speed': 5},
        {'languages': [
            'Common',
            'Dwarven'
            ]},
        {'ability_modifiers': [
            {'con': 2},
            {'wis': 1}
            ]}
    },
    'Elf': {
        {'abilities': [
            'ability1',
            'ability2'
            ]}, …
Run Code Online (Sandbox Code Playgroud)

python dictionary python-2.7

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

dictionary ×1

python ×1

python-2.7 ×1