2010年2月9日火曜日

[Python] IPアドレスを32bit整数に変換

こんな感じかな。

import socket, struct
def main():
ip = "192.168.0.1"
print struct.unpack('I', socket.inet_aton(ip))[0]
return

main()



0 件のコメント:

コメントを投稿