Python 之about IP
2016-06-14 16:08
513 查看
查看输入IP的相关信息
输入网段
你输入的IP个数为: 256
net: 192.168.1.0
netmask : 255.255.255.0
broadcast: 192.168.1.255
revere address: 1.168.192.in-addr.arpa.
subnet: 256
hexadecimal: 0xc0a80100
binary ip: 11000000101010000000000100000000
iptype: PRIVATE
输入单个主机IP
你输入的IP个数为: 1
reverse address: 50.1.168.192.in-addr.arpa.
hexadecimal: 0xc0a80132
binary ip: 11000000101010000000000100110010
iptype: PRIVATE
注:个人学习之笔记,留作个人巩固用
END!
# -*- coding:utf-8 -*- from IPy import IP #接受用户输入,参数为IP地址或网段地址 ip_s = input('Please input an IP or net-range: ').strip() ips = IP(ip_s) print('你输入的IP个数为: %s' % len(ips)) if len(ips) > 1: print('net: %s' % ips.net()) print('netmask : %s' % ips.netmask()) print('broadcast: %s' % ips.broadcast()) print('revere address: %s' % ips.reverseNames()[0]) print('subnet: %s' % len(ips)) else: print('reverse address: %s' % ips.reverseNames()[0]) print('hexadecimal: %s' % ips.strHex()) print('binary ip: %s' % ips.strBin()) print('iptype: %s' % ips.iptype())
输入网段
你输入的IP个数为: 256
net: 192.168.1.0
netmask : 255.255.255.0
broadcast: 192.168.1.255
revere address: 1.168.192.in-addr.arpa.
subnet: 256
hexadecimal: 0xc0a80100
binary ip: 11000000101010000000000100000000
iptype: PRIVATE
输入单个主机IP
你输入的IP个数为: 1
reverse address: 50.1.168.192.in-addr.arpa.
hexadecimal: 0xc0a80132
binary ip: 11000000101010000000000100110010
iptype: PRIVATE
注:个人学习之笔记,留作个人巩固用
END!
相关文章推荐
- Pyinstaller打包python代码
- python的list列表学习笔记
- Python的Flask框架中使用Flask-Migrate扩展迁移数据库的教程
- caffe预测、特征可视化python接口调用(caffe python接口调用示例)
- python 有序字典OrderedDict
- python新手中常见疑惑及解答
- Python的Flask框架中使用Flask-SQLAlchemy管理数据库的教程
- 全面了解Python的getattr(),setattr(),delattr(),hasattr()
- 浅谈python中的getattr函数 hasattr函数
- mac安装opencv+python
- Python 文件处理方法详解
- python url解析
- python基础之模块(一)
- numpy入门学习笔记
- python循环嵌套遍历前后关联的select下拉框
- python安装NumPy
- 深入解析Python中的线程同步方法
- python os模块
- 用PDB库调试Python程序
- python 字符串 大小写转换