gpt4 book ai didi

python - 缺少 python 3 API 函数

转载 作者:太空宇宙 更新时间:2023-11-04 03:52:54 26 4
gpt4 key购买 nike

我在工作时正在编写一些代码,似乎 python 提供的某些 C API 函数无法正常工作。我主要尝试了检查类型的功能,例如:

import ctypes
python33_dll = ctypes.CDLL('python33.dll')
a_float = python33_dll.PyFloat_FromDouble(ctypes.c_float(2.0))
python33_dll.PyFloat_Check(a_float)
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
python33_dll.PyFloat_Check(a_float)
File "C:\Python33\lib\ctypes\__init__.py", line 366, in __getattr__
func = self.__getitem__(name)
File "C:\Python33\lib\ctypes\__init__.py", line 371, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'PyFloat_Check' not found

我需要做些什么才能使用这个功能,还是一个错误?

docs.python.org/3.3/c-api/float.html?highlight=double#PyFloat_Check

最佳答案

PyFloat_Check()a macro .您将需要手动展开它并改为调用正确的函数。

关于python - 缺少 python 3 API 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19354061/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com