说
a = np.arange(15).reshape(3,5)
b = a - 1
b[2, 1] = 3
Pycharm在b[2]
上标记为黄色并抱怨:
Class 'int' does not define '__getitem__', so the '[]' operator cannot be used on its instances
另一方面,这没关系:
a = np.arange(15)
b = a - 1
b[2] = 3
这真是太愚蠢和烦人。如何摆脱它?