Python chr() Function

Python 内置函数Python Built-in Functions


Description

chr() takes an integer in the range (256) (i.e., 0 to 255) as a parameter and returns a corresponding character.

Syntax

The following is the syntax of the chr() method:

chr(i)

Parameters

  • i -- It can be a number in decimal or hexadecimal form.

Return Value

The return value is the ASCII character corresponding to the current integer.


Examples

The following shows examples of using the chr() method:

>>>print chr(0x30), chr(0x31), chr(0x61) # Hexadecimal 0 1 a >>> print chr(48), chr(49), chr(97) # Decimal 0 1 a

Python 内置函数Python Built-in Functions

Other Extensions