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).
ValueError
will 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 ...
随机推荐
- css学习の第一弹—格式创建
构成结构:选择符(又称为选择qi器){声明(属性:值):}*****注意:大括号,冒号,每个声明后的分号. 注释:/*注释内容写在这里*/ 一.css样式 css样式写的地方的不同分类:内联式.嵌入式 ...
- Django 2.0 学习(04):Django数据库
数据库设置/配置 打开mysite/settings.py,我们会发现Django是用的是默认的数据库SQLite,如下图所示: Django也是支持其它数据库的,比如PostgreSQL.MySQL ...
- python 检测nginx状态,若无法访问发邮件通知
应用场景:用来检测网站可用性,访问失败,则发邮件通知 #!/usr/bin/env python import urllib2,time,smtplib,string,logging from con ...
- TrueCrypt
其实很早之前就知道这个软件,不过之前没有使用,今天折腾了一把,记录下使用过程中遇见的一些问题. 百度百科: TrueCrypt,是一款免费开源的加密软件,同时支持Windows Vista,7/XP, ...
- 用js写动态时钟 2017-03-23
45每隔1秒变一次: 代码如下: <body onLoad="show()" > ------------表示当页面载入时执行该事件,可以没有 <div id ...
- Xshell提示缺失mfc110.dll
xshell 应用程序无法正常启动0xc000007b 下载 DirectX修复工具_3.3 Xshell 缺少 mfc110.dll https://www.microsoft.co ...
- 关于 promise 吃到错误的理解
关于 promise 吃到错误的理解 下面的内容需要对浏览器原生支持的 promise 的基本用法有了解,如果你还不知道 promise 和 promise 的 catch 方法,你可能需要先在 这里 ...
- MySQL聚集索引和非聚集索引
索引分为聚集索引和非聚集索引,mysql中不同的存储引擎对索引的底层实现可能会不同,这里只关注mysql的默认存储引擎InnoDB. 利用下面的命令可以查看默认的存储引擎 show variables ...
- 在Ubuntu下如何切换到超级用户
由于 Ubuntu 是基于 Debian 的 linux 操作系统,在默认的情况下,是没有超级用户(superuser, root)的,但有些系统操作必须有超级用户的权限才能进行,如手动释放内存等. ...
- 深入理解Java对象的创建过程:类的初始化与实例化
摘要: 在Java中,一个对象在可以被使用之前必须要被正确地初始化,这一点是Java规范规定的.在实例化一个对象时,JVM首先会检查相关类型是否已经加载并初始化,如果没有,则JVM立即进行加载并调用类 ...