我是在Windows上使用Python 3.9.7的ctypes初學者,我遇到了一個問題,示例如下
n = c_int(10)
print(n)
>> n = c_long(10)
為什么c_long(10)分配給n后變成
uj5u.com熱心網友回復:
可在 Windows 上重現。 是 Windows 上的大小和都是 32 位c_int的別名。c_longintlong
Python 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import *
>>> n = c_int(10)
>>> print(n)
c_long(10)
>>> c_int
<class 'ctypes.c_long'>
>>> c_long
<class 'ctypes.c_long'>
>>> c_int is c_long # two names for the same object
True
>>> x = int # just like making a new name for int
>>> x
<class 'int'>
>>> int
<class 'int'>
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/477619.html
