import socket
import struct if __name__ == '__main__':
ip = '127.0.0.1'
int_ip = struct.unpack('!I', socket.inet_aton(ip))[0]
print(int_ip)
str_ip = socket.inet_ntoa(struct.pack('!I', int_ip))
print(str_ip)

Python 将IP转换为int的更多相关文章

  1. python把str转换为int

    def str2int(s): def fn(x,y): return x+y def char2num(s): ':9}[s] return reduce(fn,map(char2num,s)) ' ...

  2. python实现IP地址转换为32位二进制

    python实现IP地址转换为32位二进制 #!/usr/bin/env python # -*- coding:utf-8 -*- class IpAddrConverter(object): de ...

  3. IP地址转换为Int

    1.转换类 import com.google.common.base.Strings; import java.security.InvalidParameterException; import ...

  4. python实现ip地址的包含关系判断

    python的IPy模块虽然可以实现一些ip地址的判断,但是不是很完美,有些场景根本判断不出来,还会抛出异常,比如一个地址范围和一个ip/掩码,这种不同类型就无法判断. 对此通过自己写函数来实现ip地 ...

  5. python开源IP代理池--IPProxys

    今天博客开始继续更新,谢谢大家对我的关注和支持.这几天一直是在写一个ip代理池的开源项目.通过前几篇的博客,我们可以了解到突破反爬虫机制的一个重要举措就是代理ip.拥有庞大稳定的ip代理,在爬虫工作中 ...

  6. python对ip地址排序、对列表进行去重

    一:使用python对ip地址排序所用代码示例一: import socket iplist = ['10.5.11.1','192.168.1.33','10.5.2.4','10.5.1.3',' ...

  7. Python的基础类型(int,bool,str):

    Python的基础类型(int,bool,str): 1.int -------> 整形:主要用力进行数字计算 2.string ------>字符串:可以保存少量数据并进行相关的操作 3 ...

  8. python匹配ip正则

    python匹配ip正则 #!/usr/bin/env python # -*- coding:utf-8 -*- import re ip_str = "asdad1.1.1.1sdfwe ...

  9. Linux C 知识 char型数字转换为int型 int型 转换为Char

    前言 在九度oj做acm的时候,经常会遇到了char类型和int类型相互转化的问题,这里进行一下总结.今后,可能会多次更新博客,因为半年做了很多总结,但是都是保存在word文档上了,现在开始慢慢向CS ...

随机推荐

  1. STL string大小写 转换

    std::string data = "This is a sample string."; // convert string to upper case std::for_ea ...

  2. WPF bmp和二进制转换

    bmp转二进制: FileStream fs = File.OpenRead(filepath); //filepath文件路径 Byte[] tempBuff = new Byte[fs.Lengt ...

  3. javadoc 工具生成开发API文档

    =====================先来一点成就感===================== package com.springMybatis.dao; import com.springMy ...

  4. Break 、Continue 和ReadOnly、Const和Ref和Out params

    Break和Continue区别 之前对于Break和Continue:ReadOnly和Const:ref和out,params之类的基础东东学习过,但是一直没有仔细去研究到底是怎么一回事儿,最近在 ...

  5. 【253】◀▶IEW-Unit18

    Unit 18 International Events 1.model1对应题目分析 The Olympic Games is a major international sporting even ...

  6. docker里安装ubuntu

    使用 Ubuntu 官方镜像 Ubuntu 相关的镜像有很多,这里使用 -s 10 参数,只搜索那些被收藏 10 次以上的镜像 $ docker search -s 10 ubuntu NAME DE ...

  7. Django 的认证系统

    Django自带的用户认证 auth 模块 from django.contrib import autu django.contrib.auth 中提供了许多方法, 这里主要介绍其中三个: auth ...

  8. Go:定时执行任务time.sleep和time.tick的优劣

    golang 写循环执行的定时任务,常见的有以下三种实现方式:1.time.Sleep方法: for { time.Sleep(time.Second) fmt.Println("我在定时执 ...

  9. spring boot jpa 使用<S extends T> List<S> findAll(Example<S> example)查询数据

    直接上代码 //查询条件对象 TinventivePrinciple time = new TinventivePrinciple(); //设置需要查询的条件(赋值) time.setIsTime( ...

  10. 初识SVN

    前言 我们都知道每一件工具的诞生都是为了方便我们的生活.SVN(Subversion)学习工具在我们"合作"开发软件过程中起到了很大的作用.说起SVN先说说SCM. 内容 SCM ...