Python内置函数(17)——chr
英文文档:
chr(i)- Return the string representing a character whose Unicode code point is the integer i. For example,
chr(97)returns the string'a', whilechr(8364)returns the string'€'. This is the inverse oford(). - The valid range for the argument is from 0 through 1,114,111 (0x10FFFF in base 16).
ValueErrorwill be raised if iis outside that range - 返回整数所对应的 unicode 字符
- 说明:
- 1. 函数返回整形参数值所对应的Unicode字符的字符串表示
>>> chr(97) #参数类型为整数
'a' >>> chr('97') #参数传入字符串时报错
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
chr('97')
TypeError: an integer is required (got type str) >>> type(chr(97)) #返回类型为字符串
<class 'str'>
2. 它的功能与ord函数刚好相反
>>> chr(97)
'a'
>>> ord('a')
97
3. 传入的参数值范围必须在0-1114111(十六进制为0x10FFFF)之间,否则将报ValueError错误
>>> chr(-1) #小于0报错
Traceback (most recent call last):
File "<pyshell#10>", line 1, in <module>
chr(-1)
ValueError: chr() arg not in range(0x110000) >>> chr(1114111)
'\U0010ffff' >>> chr(1114112) #超过1114111报错
Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
chr(1114112)
ValueError: chr() arg not in range(0x110000)
Python内置函数(17)——chr的更多相关文章
- Python内置函数(10)——chr
英文文档: chr(i) Return the string representing a character whose Unicode code point is the integer i. F ...
- Python内置函数之chr()
参数是一个整型对象: chr(integer) 返回整型对应的Unicode字符对象. 例子: >>> chr() '\x0c' >>> chr() 'ⲓ' > ...
- Python内置函数(17)——divmod
英文文档: divmod(a, b) Take two (non complex) numbers as arguments and return a pair of numbers consisti ...
- 17.python内置函数2
python内置函数1:https://www.cnblogs.com/raitorei/p/11813694.html # max,min高级玩法 # l=[1,3,100,-1,2] # prin ...
- 【转】python 内置函数总结(大部分)
[转]python 内置函数总结(大部分) python 内置函数大讲堂 python全栈开发,内置函数 1. 内置函数 python的内置函数截止到python版本3.6.2,现在python一共为 ...
- python 内置函数总结(大部分)
python 内置函数大讲堂 python全栈开发,内置函数 1. 内置函数 python的内置函数截止到python版本3.6.2,现在python一共为我们提供了68个内置函数.它们就是pytho ...
- Python之路(第八篇)Python内置函数、zip()、max()、min()
一.python内置函数 abs() 求绝对值 例子 print(abs(-2)) all() 把序列中每一个元素做布尔运算,如果全部都是true,就返回true, 但是如果是空字符串.空列表也返回t ...
- python内置函数详细介绍
知识内容: 1.python内置函数简介 2.python内置函数详细介绍 一.python内置函数简介 python中有很多内置函数,实现了一些基本功能,内置函数的官方介绍文档: https: ...
- 【286】◀▶ Python 内置函数说明
参考: Python 内置函数 01 abs() 返回数字的绝对值. 02 all() 用于判断给定的可迭代参数 iterable 中的所有元素是否不为 0.''.False 或者 itera ...
随机推荐
- Mybatis动态SQL单一基础类型参数用if标签
Mybatis动态SQL单一基础类型参数用if标签时,test中应该用 _parameter,如: 1 2 3 4 5 6 <select id="selectByName" ...
- Tencent研发工程师笔试知识点
一: 32位编译器:32位系统下指针占用4字节 char :1个字节 char*(即指针变量): 4个字节(32位的寻址空间是2^32, 即32个bit,也就是4个字节.同 ...
- PostGis常用函数中文介绍
记录常用PostGis常用函数: 1.OGC标准函数 管理函数: 添加几何字段 AddGeometryColumn(, , , , , ) 删除几何字段 DropGeometryColumn(, , ...
- Cesium解决按住滚轮旋转时进入地下的问题
viewer.clock.onTick.addEventListener(function () { setMinCamera()}) var setMinCamera = functi ...
- LNMP+FARM+DNS
LNMP 1.安装Nginx前的环境. # yum -y install gcc gcc-c++ pcre-devel zlib-devel openssl-devel 2.添加www系统用户,在 ...
- 使用async和wait进行异步编程
本文来源于博客园-钱智慧,转载请注明出处 代码示例 // 要让一个方法成为异步方法: // - async修饰符. // - 返回类型是 Task 或者 Task<T>. 具体来说,如果函 ...
- nodejs轻量级时间格式化组件Moment.js的使用例子
在项目中,经常使用时间进行格式化的输出,以及转换,同时做时间的统计,原本js原生的时间函数比较复杂繁琐,不适合快速开发使用. 轻量级的moment.js很好的解决了这些问题. 下面以简单的例子进行mo ...
- 用session做权限控制
一个需要用户进行登录的网站,基本上都会设置用户权限,对不同的用户进行权限控制.例如:一个网站肯定会有一个管理员管理着普通的用户,普通的用户不可能对其他用户有着类似于增删改查等操作,这样网站都乱了--, ...
- Java设计模式-模板模式
介绍:模板模式定义了一个模板抽象类,这个抽象类中定义了方法调用的形式,顺序.子类通过重写对方法进行实现,但是调用方式不能改变. 模板模式中的模板中定义了核心的代码骨架,一些有着不同方式实现的代码放在子 ...
- Java Arrays 源码 笔记
Arrays.java是Java中用来操作数组的类.使用这个工具类可以减少平常很多的工作量.了解其实现,可以避免一些错误的用法. 它提供的操作包括: 排序 sort 查找 binarySearch() ...