2013-07-10 20 views

回答

1

的Python 2.7.3

import socket, struct 

packed_value = struct.pack('!I', 4294967295 & int('-1136577616')) 
addr = socket.inet_ntoa(packed_value) 

print addr 

對於Python 3.3+看到using inet_ntoa function in Python

+0

如何拿回多少?在[49]中:struct.unpack('> L',socket.inet_aton('188.65.51.176'))[0] Out [49]:3158389680L – avdoshkin

+0

4294967295&int(' - 1136577616')== 3158389680L。你不能得到更好的結果。你不能反轉'&'(位AND)。 7&1 = 1和5&1 = 1,所以不同的數字給出相同的結果。 – furas

+0

如何獲得結果呢? – avdoshkin