【发布时间】:2019-08-27 23:55:35
【问题描述】:
我正在尝试将“嵌套字典切片”分配给另一个变量。
a = {first:{1:'abc', 2: 'def', 3:'ghi'}, second: {1: 'jkl', 2: 'mno', 3: 'pqr'}, third: {1:'stu', 2:'vwx', 3:'yza'}
b = a[first][6:]
但它说:
TypeError: unhashable type: 'slice'
还有其他方法吗?
【问题讨论】:
-
新变量的预期值是多少?
标签: python-3.x dictionary slice