python 获取远程设备ip地址
2020-12-13 02:19
标签:The bsp ons try network 设备 for rem -- python2.7 输出 python 获取远程设备ip地址 标签:The bsp ons try network 设备 for rem -- 原文地址:https://www.cnblogs.com/sea-stream/p/11031500.html#!/usr/bin/env python
# Python Network Programming Cookbook -- Chapter - 1
# This program is optimized for Python 2.7.
# It may run on any other version with/without modifications.
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()
IP address of www.python.org: 151.101.108.223
上一篇:Java中的反射机制