码迷,mamicode.com
首页 > 编程语言 > 详细

Python GET REMOTE SERVER'S INFO

时间:2015-12-21 16:10:20      阅读:180      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!