ch(),unichr(),ord()

 
A function with an integer in the range of range (256) chr () as an argument and returns a corresponding character.
 
>>>chr(65)
 
'A'
 
 
unichr () with chr (), in that it returns Unicode characters.
 
>>>unichr(12345)
 
u'u3039
 
Beyond the scope of an exception report ValueErrro
 
 
the ord () function is CHR () or unichr () paired function to characters as arguments, return values ​​ASCII or Unicode values.
 
>>>ord('a')
 
97
 
 
for i in range(ord('a'),ord('z') + 1):
    print (str(i)+' '+ chr(i))    #同print (str(i)+' '+ unichr(i))
 
Output:
97 a
98 b
99 c
100 d
101 e
102 f
103 g
104 h
105 i
106 j
107 k
108 l
109 m
110 n
111
112 p
113 q
114 r
115 s
116 t
117 in
118 v
119 w
120 x
121 and
122
 
 
 

Guess you like

Origin www.cnblogs.com/myshuzhimei/p/11756113.html