博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python 获取远程设备ip地址
阅读量:4564 次
发布时间:2019-06-08

本文共 600 字,大约阅读时间需要 2 分钟。

 

python2.7

#!/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 socketdef 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

 

转载于:https://www.cnblogs.com/sea-stream/p/11031500.html

你可能感兴趣的文章
Ubuntu上kubeadm安装Kubernetes集群
查看>>
关于java学习中的一些易错点(基础篇)
查看>>
MFC的多国语言界面的实现
查看>>
四则运算个人项目 最终版
查看>>
java线程系列---java5中的线程池
查看>>
SQL表连接
查看>>
新秀系列C/C++经典问题(四)
查看>>
memset函数具体说明
查看>>
经常使用的android弹出对话框
查看>>
确保新站自身站点设计的合理性的六大注意点
查看>>
promise
查看>>
Go 网络编程笔记
查看>>
[]Java面试题123道
查看>>
中间件与auth认证的那点儿所以然
查看>>
Scala
查看>>
Android 中LinearLayout控件属性
查看>>
面向对象之多态性
查看>>
树状数组
查看>>
【2019.8.14 慈溪模拟赛 T1】我不是!我没有!别瞎说啊!(notme)(BFS+DP)
查看>>
多任务--进程 及 进程间通信
查看>>