int(x [,base ])         将x转换为一个整数  
long(x [,base ])        将x转换为一个长整数  
float(x )               将x转换到一个浮点数  
complex(real [,imag ])  创建一个复数  
str(x )                 将对象 x 转换为字符串  
repr(x )                将对象 x 转换为表达式字符串  
eval(str )              用来计算在字符串中的有效Python表达式,并返回一个对象  
tuple(s )               将序列 s 转换为一个元组  
list(s )                将序列 s 转换为一个列表  
chr(x )                 将一个整数转换为一个字符  
unichr(x )              将一个整数转换为Unicode字符  
ord(x )                 将一个字符转换为它的整数值  
hex(x )                 将一个整数转换为一个十六进制字符串  
oct(x )                 将一个整数转换为一个八进制字符串

其中oct()stat模块中获取的st_mode中可用来将文件权限转换为chmod 类型的,方便查看。

python各种类型转换-int,str,char,float,ord,hex,oct等的更多相关文章

  1. [No000066]python各种类型转换-int,str,char,float,ord,hex,oct等

    int(x [,base ]) #将x转换为一个整数 long(x [,base ]) #将x转换为一个长整数 float(x ) #将x转换到一个浮点数 complex(real [,imag ]) ...

  2. 【python】python各种类型转换-int,str,char,float,ord,hex,oct等

    [python] int(x [,base ])         将x转换为一个整数 long(x [,base ])        将x转换为一个长整数 float(x )             ...

  3. Python整型int、浮点float常用方法

    #!/usr/bin/env python # -*- coding:utf-8 -*- # Python整型int.浮点float # abs(x) # 返回数字的绝对值,如abs(-10) 返回 ...

  4. Arduino中数据类型转换 int转换为char 亲测好使,itoa()函数

    由于博主最近在做一个项目,需要采集不同传感器的数据,包括float型的HCHO,以及int型的PM2.5数据.但是最终向服务器上传的数据都得转换为char型才能发送,这是借鉴了一个github上面的实 ...

  5. python数据类型,int,str,bool

    一,python中的int() int在python中主要用来运算,对字符串的转化,用int(str)表示,并且需要str.isdigit为真. 在int()中二进制的转换如下: #bit_lengt ...

  6. Python 基本类型转换

    python 有关字符串处理有哪些好用的方法?reverse len 字符串分割,合并?截取?查找? find index join split unicode字符串的表示 ""& ...

  7. cocos2d-x类型转换(CCstring int string char UTF-8互转)

    在做数据转换时,最好包含以下头文件 #include <iostream> #include <cmath> #include <string> #include  ...

  8. C++ char float int string 之间的转换

    string str = "123"; string 转 int int i = atoi( str.c_str() ); string 转 float float f = ato ...

  9. python基础-2 编码转换 pycharm 配置 运算符 基本数据类型int str list tupple dict for循环 enumerate序列方法 range和xrange

    1.编码转换 unicode 可以编译成 UTF-U GBK 即 #!/usr/bin/env python # -*- coding:utf-8 -*- a = '测试字符' #默认是utf-8 a ...

随机推荐

  1. pandas库学习笔记(一)Series入门学习

    Pandas基本介绍: pandas is an open source, BSD-licensed (permissive free software licenses) library provi ...

  2. cadence 机械孔的制作

    在平时画PCB的时候,会用到安装孔,好多人就是找个过孔,在原理图中连接GND,这样使用也可以,下面介绍一种正经机械孔的制作方法(自己摸索的),制作一个孔径为3mm的安装孔. 1 打开pad desig ...

  3. C# Socket连接请求超时机制

    作者:RazanPaul 译者:Todd Wei 原文:http://www.codeproject.com/KB/IP/TimeOutSocket.aspx 介绍 您可能注意到了,.Net的Syst ...

  4. kendo ui template的用法

    kendo ui template的用法: Kendo UI 框架提供了一个易用,高性能的JavaScript模板引擎.通过模板可以创建一个HTML片段然后可以和JavaScript数据合并成最终的H ...

  5. LintCode-Majority Number

    Given an array of integers, the majority number is the number that occurs more than half of the size ...

  6. .Xresources 配置文件

    安装rxvt-unicode-256color,如果不是这个版本的话VIM配色会显示不正常. ~/.Xresources配置文件如下 !urxvt color scheme: URxvt*backgr ...

  7. Codeforces Round #302 (Div. 2) D. Destroying Roads 最短路

    题目链接: 题目 D. Destroying Roads time limit per test 2 seconds memory limit per test 256 megabytes input ...

  8. 【BZOJ】【1026】【SCOI2009】Windy数

    数位DP cxlove基础数位DP第三题 = =预处理是个很有用的东西!然后就是分类讨论! /***************************************************** ...

  9. 【Vijos】【1164】曹冲养猪

    中国剩余定理 没啥重要的……模板题,中国剩余定理就是解出模线性方程组的一个可行解(好像也是唯一解?) 这是一种神奇的构造方法……明白了为什么这样构造是对的就行了=.=至于怎么想到这种构造方法的……去问 ...

  10. 一些css效果积累

    悬浮效果: ul li a{text-decoration: none;color: black}  ul li a:hover{color: blue}   鼠标变小手 span:hover{cur ...