Home  >  Article  >  Backend Development  >  python在Windows8下获取本机ip地址的方法

python在Windows8下获取本机ip地址的方法

WBOY
WBOYOriginal
2016-06-06 11:22:391187browse

本文实例讲述了python在Windows8下获取本机ip地址的方法。分享给大家供大家参考。具体实现方法如下:

import socket 
hostname = socket.gethostname() 
IPinfo = socket.gethostbyname_ex(hostname) 
LocalIP = IPinfo[2][2] 
print LocalIP

希望本文所述对大家的Python程序设计有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn