[python-chinese] python 中如何得到当前机子的 ip 地址

Andelf andelf在gmail.com
星期二 四月 17 18:31:12 HKT 2007


在07-4-17,尹祥龙 <yinxianglong at gmail.com> 写道:

> import socket
> print socket.gethostbyname(socket.gethostname())
>

linux下大多得到的是127.0.0.1
用ifconfig扣出来,或者
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/439094



判断通不通..测试访问个网站看看
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://python.cn/pipermail/python-chinese/attachments/20070417/ea990750/attachment.html 


关于邮件列表 python-chinese 的更多信息