Python:TypeError: function object is not subscriptable

X_train, X_test, y_train, y_test = train_test_split(wine_dataset['data'], wine_dataset['target'], random_state = 0)

以上语句在jupytet notebook报错 : TypeError: ‘function’ object is not subscriptable

解决办法:
给wine_dataset[‘data’] 和 wine_dataset[‘target’] 加上括号:
wine_dataset([‘data’]), wine_dataset([‘target’])

像这种问题TypeError: ‘function’ object is not subscriptable
一般都是由于函数没加括号导致的;

你可能感兴趣的:(Python)