首页 > 编程语言 > 详细

Python GET REMOTE SERVER'S INFO

时间:2015-12-21 16:08:10      阅读:326      评论:0      收藏:0      [点我收藏+]
 1 #!/usr/bin/env python
 2 #--*-- coding:utf-8 --*--
 3 # Python Network Programming Cookbook -- Chapter – 1
 4 # This program is optimized for Python 2.7.
 5 # It may run on any other version with/without modifications.
 6 import socket
 7 def get_remote_machine_info():
 8     remote_host = www.python.org
 9     try:
10         print "IP address: %s" %socket.gethostbyname(remote_host)
11     except socket.error, err_msg:
12         print "%s: %s" %(remote_host, err_msg)
13 
14 if __name__ == __main__:
15     get_remote_machine_info()

TEST:

IP address: 23.235.43.223
[Finished in 0.1s]

Python GET REMOTE SERVER'S INFO

原文:http://www.cnblogs.com/magicpower/p/5063385.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!