1
我是Python新手,我的意思是它们如何实现的区别。Python中对象的属性和方法之间的联系是什么?
例如:
>>> a=np.array([1,2,5,3,43])
>>> a.sort()
>>> a
array([ 1, 2, 3, 5, 43])
>>> a=np.array([1,2,5,3,43])
>>> a.shape
(5,)
>>> a.sort()
>>> a
array([ 1, 2, 3, 5, 43])
>>> a.sort
<built-in method sort of numpy.ndarray object at 0x7f78e358a9e0>
>>> a.shape()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'tuple' object is not callable
也许答案应该是像在Python
属性是一个值。一种方法是一个“功能”。 – DyZ
@DYZ我的意思是他们之间有什么**链接**?我听说过_ _ foo _ _,关于“__”的任何事情? – Statham
没有链接。他们是无关的,除了两者属于同一个对象。 – DyZ