1. 程式人生 > >python中實現字元與其ASCII碼間的轉換

python中實現字元與其ASCII碼間的轉換

chars  =  'a'
# Get the ASCII number of a character
number = ord(chars)

number = 48
# Get the character given by an ASCII number
chars = chr(number)


如果是Unicode字元,可以使用ord()和unichr()函式。