【发布时间】:2019-08-30 12:29:34
【问题描述】:
我正在创建一个类并设置一些属性。我将字典作为类对象引用。但无法访问对象的第二个元素。
我试图用谷歌搜索这个问题,但它没有说明问题的原因。
data = {
'a': {
'vsdf': 'asfas',
'nfgn': 'aser',
'aser': 'rtydf'
},
'b': ['ndfg', 'ndf', 'safd']
}
My class looks something like this:
def __init__(self, meta):
self.meta = meta
and when i create the object of this class like this:
request = Request(data)
and try to print the request['b'] it shows the error "'Request' object is not subscriptable"
实际结果应该是这样的: ['', '', '']
但它显示: “请求”对象不可下标
【问题讨论】:
标签: python-3.x class object