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)
转载于:https://www.cnblogs.com/lincappu/p/8144762.html
Python内置函数(17)——chr相关推荐
- python中chr函数的用法_【转】Python内置函数(10)——chr
英文文档: chr(i) Return the string representing a character whose Unicode code point is the integeri. Fo ...
- python 内置函数ord()和chr()函数用法详解
python 中的ord()函数和chr()函数 需要对字符进行转换时使用 其中ord函数可以将字符转化为你所需要的ASCII码,chr函数可以将0-255中的任一整数转化为你所需要的字符. 通过这样 ...
- python内置函数返回序列中最大元素_Python之路(第八篇)Python内置函数、zip()、max()、min()...
一.python内置函数 abs() 求绝对值 例子 print(abs(-2)) all() 把序列中每一个元素做布尔运算,如果全部都是true,就返回true, 但是如果是空字符串.空列表也返回t ...
- python内置函数返回元素个数_Python内置函数
Python Python开发 Python语言 Python内置函数 Python内置函数 一.内置函数 什么是内置函数? 就是python给你提供的. 拿来直接⽤的函数, 比如print, inp ...
- python内置函数用来返回列表、元组、字典_python程序设计第一章基础知识 题库及选解...
由于学校的python是笔试,所以找了份感觉比较好的题库刷了下其中前八章的填空和判断,附上选解.各章链接如下 填空 1. Python安装扩展库常用的是()工具.(pip) 2. Python标准库m ...
- 大学计算机python编程的函数及作用总结_【转】python 内置函数总结(大部分)...
python 内置函数大讲堂 python全栈开发,内置函数 1.内置函数 python的内置函数截止到python版本3.6.2,现在python一共为我们提供了68个内置函数.它们就是python ...
- python内置函数用来返回序列中的最小元素_1000道Python题库系列分享二(48道)
1.10 pip list 1.11 对 1.12 错 1.13 错 1.14 错 1.15 对 1.16 错 1.17 对 本期题目: 2.1 表达式int('11111', 2)的值为______ ...
- 【Python知识点梳理】5.Python内置函数
5.Python内置函数 文章目录 1.内置函数简介 2.数据运算 3.类型转换 4.序列操作 5.Set集合 7.其他内置函数 6.综合练习 总结 1.内置函数简介 任何一门编程语言的核心操作都 ...
- 列举5个python内置函数和使用方法_python内置函数是什么
python内置函数如下表 用法及说明 1.abs(),返回数字的绝对值. 2.all(),如果集合中所有元素是true或集合为空集合,返回True. 3.any(),如果集合中有一项元素是true, ...
- Python入门之 Python内置函数
Python入门之 Python内置函数 函数就是以功能为导向,一个函数封装一个功能,那么Python将一些常用的功能(比如len)给我们封装成了一个一个的函数,供我们使用,他们不仅效率高(底层都是用 ...
最新文章
- ls 中一些你不知道的事
- 华为、北大、悉尼大学:最新视觉Transformer综述(2017-2020年)
- C Primer Plus_第8章_字符输入输出和输入确认_编程练习
- DL之SqueezeNet:SqueezeNet算法的架构详解
- python算法与数据结构-插入排序算法
- php使用邮件找回密码,php利用Zend_Mail发送邮件(实现邮件重设密码功能)
- MySQL执行外部sql脚本文件的命令( source命令执行sql )
- mysql oracle 备份数据库备份_完整备份Oracle数据库
- 如何制作一个基于Tile的游戏 Cocos2d-x 2 0 4
- pe我的手机服务器存档文件,我的世界手机版怎么导出存档 pe版怎么把存档给别人用...
- Day01 - 打开Linux大门
- 钉钉/企业微信对接用友T+生成财务凭证准备资料
- JS 阻止键盘输入event.preventDefault 和window.event.returnValue
- photoshop笔记
- 聊聊电商系统中红包活动设计
- 香港美食攻略(3)——源记喳咋
- 函数的调用(传值调用和传址调用)
- 如何快速下载Google play里软件APK
- NoMeiryoUI v3.1.0 开源便捷的Windows系统字体设置工具
- Pr 入门教程:如何倾斜移位效果?