python的chr()和ord()函数
来源:互联网 发布:学seo前要做什么工作 编辑:程序博客网 时间:2024/05/08 12:30
在编程的时候,我们会遇到处理ASCII码的时候,我们需要在字符和其ASCII码之间进行转换。
python中的chr()函数和ord()函数给我们提供了便利。
chr()函数
我们举个例子:查阅ASCII码表我们知道字母“A”对应的ASCII码值为65.
>>> chr(65)'A'
从这个例子我们可以看到chr()函数要输入一个整型参数,且其范围为0~255
>>> chr(256)Traceback (most recent call last): File "<stdin>", line 1, in <module>ValueError: chr() arg not in range(256)
ord()函数
其功能正好与chr()函数相反,如:
>>> ord('A')65
这两个函数很方便,大家可以在编程的时候注意使用。
end
阅读全文
0 0
- python的chr()和ord()函数
- python chr()和ord()函数
- python: ord & chr 函数
- python中chr()和ord()函数的用法
- python chr()和ord()
- python chr()和ord()
- python chr()和ord()
- python chr()和ord()
- python chr()和ord()
- python的chr()、unichr()和ord()
- python ord() chr() unichr() 函数
- python chr()、unichr()和ord()
- Python中int和ord函数,str和chr函数,find和index之间的差别
- Python的chr()、unichr()、ord()
- python中chr与ord函数的使用
- 飘逸的python - ord和chr以及unichr
- Python内置函数chr() unichr() ord()
- Python 函数 —— ord(), chr()
- java对象的强引用,软引用,弱引用和虚引用
- 行为型模式之访问者模式实现
- oscache如何缓存页面及如何强制清除指定页面的缓存
- Android---多线程:继承Thread 类和实现Runnable 接口的区别
- 小羊生小羊
- python的chr()和ord()函数
- vs2015如何使用pthread.h文件
- Anzdroid数据存储——SQLite
- 51单片机简易烧录方法
- python:将一个外部函数,转化为类中的方法
- UBOOT需要知道的计算机组成原理
- Android中的内部类(以View的点击事件为例)
- Linux学习——yum学习和光盘yum源搭建
- spring框架学习(三)junit单元测试