python:ip地址转换到数字
来源:互联网 发布:linux ntpclient 命令 编辑:程序博客网 时间:2024/05/26 12:57
在工作中需要将ip地址从字符串到整数。脚本语言可以提供快速的方式实现,在python中,:
代码如下
!/usr/bin/env python
# coding: utf-8
#这是一个IP转换为整数的程序
import struct,socket
def Ip2Int(ip):
return struct.unpack("!L",socket.inet_aton(ip))[0]
if __name__ == '__main__':
print Ip2Int('202.99.96.68')
这个库的使用可参考的手册:
http://www.python.org/doc/2.5.2/lib/module-socket.html
参考
http://hi.baidu.com/wg_wang/blog/item/69ba3330ec5a0b9fa8018e63.html
http://acen-chen.javaeye.com/blog/290163
- python:ip地址转换到数字
- IP到数字转换
- 用Python来在IP地址和数字之间转换
- python IP 地址和数字之间的转换
- python ip地址转换
- python ip地址转换
- python转换IP地址
- python ip地址转换
- IP地址数字相互转换
- IP地址与数字地址相互转换
- 域名到ip地址转换
- ip地址 转换为数字的公式
- ip地址,字符串、数字格式转换
- 怎样将IP地址转换为数字
- 怎样将IP地址转换为数字
- IP地址和数字的转换
- MySQL中时间-->数字转换和IP地址-->数字转换
- C# IP地址和整数之间的转换,IP地址和数字ip地址的转换
- java实现快速排序
- 几种压缩算法原理介绍
- 如何察看Solaris系统的内存大小及使用情况?
- 取得MAC地址的4种方法
- _beginthread还是CreateThread
- python:ip地址转换到数字
- 虚拟机之比较,lua 5 的实现
- 创建一个与其他表一样结构的表
- MFC调试工具——之BoundsChecker用法
- 在Spring中配置log4j
- Are Cloud Based Memory Architectures the Next Big Thing
- 程序员的十层楼 大哲
- [调侃][观点]男人容易么?饶了他们吧!(作者:韩蓄瑶)
- FireFox flash player 文字乱码问题的解决--linux 下通通快快上开心网