Python值的性质需要澄清

2024-05-19 17:06:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我刚读完http://python.net/crew/mwh/hacks/objectthink.htmlhttp://nedbatchelder.com/text/names.html。你知道吗

现在有一个问题,Python值总是对象吗(对象是名称唯一可以绑定的对象吗?)而且,在PyTown中对象是唯一的游戏吗…因为语言没有原语,对吗?你知道吗


Tags: 对象text名称comhttp游戏netnames
1条回答
网友
1楼 · 发布于 2024-05-19 17:06:53

是的,一路都是物体。你知道吗

例如,整数具有以下方法:

>>> 1 .__str__
<method-wrapper '__str__' of int object at 0x104ad7820>

功能也是如此:

>>> def foo(): pass
... 
>>> foo.__str__
<method-wrapper '__str__' of function object at 0x104e62830>

相关问题 更多 >