Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

The Python chr() function

The Python chr() function

Python built-in function Python built-in function


Description

chr() takes an integer in the range(256) (that is, 0-255) as a parameter and returns the corresponding character.

Syntax

The syntax of the chr() method is as follows:


chr(i)

Parameters

Return Value

Returns the ASCII character corresponding to the current integer.


Example

The following examples show the use of the chr() method:

print

chr

(

0

x30

)

,

chr

(

0

x31

)

,

chr

(

0

x61

)

Hexadecimal

0

1

a

print

chr

(

48

)

,

chr

(

49

)

,

chr

(

97

)

Decimal

0

1

a

Python built-in function Python built-in function