python的chr()和ord()函数
2017-06-16 22:07
429 查看
在编程的时候,我们会遇到处理ASCII码的时候,我们需要在字符和其ASCII码之间进行转换。
python中的chr()函数和ord()函数给我们提供了便利。
从这个例子我们可以看到chr()函数要输入一个整型参数,且其范围为0~255
这两个函数很方便,大家可以在编程的时候注意使用。
end
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
相关文章推荐
- 浅谈Python中chr、unichr、ord字符函数之间的对比
- python ord() chr() unichr() 函数
- python chr()和ord()函数
- python: ord & chr 函数
- 浅谈Python中chr、unichr、ord字符函数之间的对比
- python中chr()和ord()函数的用法
- Python 函数 —— ord(), chr()
- python中hex,oct,chr,ord函数讲解
- python学习笔记 --- python中使用哈希方法处理字符与数字,ord()等函数详解
- Python chr() ord() unichr()
- PHP函数篇之掌握ord()与chr()函数应用
- Delphi System 提供的编译期函数(Dec,Inc,Odd,Pred,Succ,Ord,Chr,Low,High,Sizeof)
- php中的字符串常用函数(四) ord() 获得字符的ascii码 chr()获取ascii码对应的字符
- python ord()函数可取得 字符 ascii码值
- Python 中的lower()、upper()函数和str\chr
- 飘逸的python - ord和chr以及unichr
- python ord()与chr()用法以及区别
- 【跟我一起学python吧】python chr()、unichr()和ord()
- PHP函数篇之掌握ord()与chr()函数应用
- chr()、unichr()和ord(),全半角转换,ValueError: unichr() arg not in range() (wide Python build)