How to get the signed integer value of a long in python?

后端 未结 6 1783
攒了一身酷
攒了一身酷 2020-12-08 15:40

If lv stores a long value, and the machine is 32 bits, the following code:

iv = int(lv & 0xffffffff)

results an iv of type long, inst

6条回答
  •  独厮守ぢ
    2020-12-08 15:55

    import ctypes
    
    number = lv & 0xFFFFFFFF
    
    signed_number = ctypes.c_long(number).value
    

提交回复
热议问题