我是一个初学者在Windows上使用Python3.9.7,我遇到了一个问题,示例如下
n = c_int(10)
print(n)
>> n = c_long(10)
为什么赋值给n后变成c_long(10)
c_int
是c_long
的别名,因为int
和long
的大小在Windows上都是32位的。
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'>