Bunch和字典结构类似,也是由键值对组成,和字典区别:其键值可以被实例对象当作属性使用。
In [1]: from sklearn.datasets import base
...: buch = base.Bunch(A=1,B=2,c=3)
...:
In [2]: type(buch)
Out[2]: sklearn.datasets.base.Bunch
In [3]: buch
Out[3]: {'A': 1, 'B': 2, 'c': 3}
In [4]: buch['A']
Out[4]: 1
In [5]: buch.A#对象.属性
Out[5]: 1
In [6]: dt = {'A':1,'B':2,'C':3}
In [7]: type(dt)
Out[7]: dict
In [8]: dt['A']
Out[8]: 1
In [9]: dt.A
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-9-7b8328c57719> in <module>()
----> 1 dt.A