如何从python中的地址获取值

Pra*_*tik 2 python

我正在尝试从 Python 中的地址读取值。

假设我在变量中有一个地址: address_vble= 0x900045A1

在C中,我们可以得到 value = *address_vble

我如何在 Python 中做同样的事情?

感谢您的帮助。

JON*_*JON 11

你可以通过 ctypes 找到它

>>>import ctypes
>>>a = 5
>>>address = id(a)
>>>address
493382800
>>>ctypes.cast(address, ctypes.py_object).value
5
Run Code Online (Sandbox Code Playgroud)

希望它会帮助你!