1.python写法
import socket
def get_remote_machine_info():
remote_host = 'www.python.org'
try:
print "IP address of %s: %s" %(remote_host, socket.gethostbyname(remote_host))
except socket.error, err_msg:
print "%s: %s" %(remote_host, err_msg)
if __name__ == '__main__':
get_remote_machine_info()
2.php写法
<?php
function get_remote_machine_info(){
$remote_host = 'www.python.org';
try{
printf("IP address of %s: %s\n", $remote_host, gethostbyname($remote_host));
}catch(Exception $e){
printf("%s: %s\n", $remote_host, $e->getMessage());
}
}
get_remote_machine_info();
代码比较简单 但执行起来还是php比较慢~
转载请标注原文地址:http://blog.csdn.net/ddjohn/article/details/49930455