python code base --ASCII

 

 ord () and chr ()

  • the ord () function is CHR () function (for 8-bit ASCII string) pairing function, which takes a string (Unicode character) as a parameter and returns the value corresponding to ASCII or Unicode value
  • CHR () returns an integer value corresponding to the current ASCII characters
>>> ord('a')
97
>>> ord('z')
122
>>> ord('A')
65
>>> ord('Z')
90
>>> chr(65)
'A'
>>> chr(90)
'Z'
>>> chr(97)
'a'
>>> chr(122)
'z'

 

 

# Letter az calculate a sum of ASCII code

>>> result = 0
>>> for i in range(ord('a'),ord('z')+1):
...     result +=i
...
>>> print(result)
2847

 

Guess you like

Origin www.cnblogs.com/wenm1128/p/11555415.html