import ctypes
print(id(8)-id(7))
def newint(an,new):
ctypes.memmove(id(an)+24,id(new)+24,8)
#id(x)+n,n must be 24. The third variable must be a non-integer
an=8
another=8
newint(an,20)
print(an,another)
输出为:
32
20 20
*python2中可能需要更改
(更改自微信公众号:Python程序员/诡异的Python整数)