很简单的python问题

来源:百度知道 编辑:UC知道 时间:2024/06/05 07:47:48
把ASCII码转换成字母的方程是chr(),那把字母转换成对应的ASCII码要怎么办呢?

ord()

Strings
The items of a string are characters. There is no separate character type; a character is represented by a string of one item. Characters represent (at least) 8-bit bytes. The built-in functions chr() and ord() convert between characters and nonnegative integers representing the byte values. Bytes with the values 0-127 usually represent the corresponding ASCII values, but the interpretation of values is up to the program. The string data type is also used to represent arrays of bytes, e.g., to hold data read from a file.