* 作者:煮酒品茶 tea
* 博客:http://www.zwhset.com http://cwtea.blog.51cto.com
* 目前在京峰教育担任python讲师
#0、Ascii码转换 ord chr unichr
> 在python里,其实对assic码的值进行转换啊查询并不是特别多,做到基础掌握就行。
Ascii码表:
![](https://box.kancloud.cn/a6cf8ab14457165a088d7d4e9efdaa08_750x507.jpg)
#1、函数原型
~~~
ord(...)
ord(c) -> integer #返回整型
Return the integer ordinal of a one-character string.
chr(...)
chr(i) -> character #返回Assic码对象
Return a string of one character with ordinal i; 0 <= i < 256.
unichr(...)
unichr(i) -> Unicode character #返回unicode的assic码对象
Return a Unicode string of one character with ordinal i; 0 <= i <= 0x10ffff.
~~~
#2、样例
~~~
In [18]: chr(65) # 取Ascii码65的值
Out[18]: 'A'
In [19]: ord('A') # 取字符A的Ascii码的值
Out[19]: 65
In [20]: ord('a') # 取字符a的Ascii码的值
Out[20]: 97
In [22]: unichr(65) # 取Ascii码65的值,结果是unicode
Out[22]: u'A
~~~
- python核心
- python27编译安装
- 原处修改以及拷贝
- loop
- 内置的变量
- 内置类型
- python内置方法
- 内置方法列表
- 求绝对值-abs
- 求商取余-divmod
- 交换输入-input
- [未完]文件打开函数-open
- staticmethod
- 判断迭代对象真假all
- 判断迭代对象真假any
- 枚举对象enumerate
- 整数转换类型int
- ascii码转换ord-chr-unichr
- 类型转换str
- python执行字符串表达式eval
- 类型判断isinstance
- 数学计算pow
- 数学计算和sum
- 不可变集合frozenset
- zip
- 比较cmp
- basestring类型判断
- 反转序列迭代器resversed
- python模块
- glob
- sys.argvgetopt-argparse
- os
- sys
- requests
- random
- time
- date
- zlib-gzip-bz2-zipfile-tarfile
- ftp
- paramiko
- pexpect
- 数据库模块
- redis
- mysql
- mongodb
- __builtin__
- 学生PYTHON分享
- 学生运维分享