首页 > 解决方案 > CPython 中的 _PyObject_GetAttrId() 是什么?

问题描述

我在 CPython 中查看了 sysmodule.c 并遇到了这段代码stdin_encoding = _PyObject_GetAttrId(fin, &PyId_encoding);,但我找不到它的任何文档。

是什么_PyObject_GetAttrId()

https://github.com/python/cpython/blob/master/Python/sysmodule.c#L597

标签: pythoncpython-3.xinterpretercpython

解决方案


我的假设是它是 python__getattr__魔术方法的实现。

查看此魔法方法列表以获取更多信息。


推荐阅读