2011-12-05 36 views
-1

例如在Python:如何將IPv4地址轉換爲整數並返回C?

number = struct.unpack('!L', socket.inet_aton(ip))[0] 
ip = socket.inet_ntoa(struct.pack('!L',number)) 
+1

做過谷歌工作嗎?爲什麼這裏有這麼多這樣的問題? – Ulterior

+1

@Ulterior:其實,SO非常受歡迎,即使Google在這裏尋找答案。 – mouviciel

+0

@mouviciel,谷歌是如此雜食,他甚至屈就於尋找答案,因此:) –

回答

2

inet_addrinet_atoninet_ntoa,也有相當多的功能,嘗試查找的文檔。