December 30, 2019 MRKJ string formatting page143

'% [-] [. N] [+] [0] [m] formatting characters'% exp

import math
print(math.pi)

>>>>

3.141592653589793

= S ' life is short, I Python ' 
Z = s.encode (encoding = ' UTF-. 8 ' ) # coding 
Print (Z) # output binary data 

X = z.decode (encoding = ' UTF-. 8 ' ) # decoding 
Print (X)

>>>

b '\ xe4 \ xba \ xba \ xe7 \ x94 \ x9f \ xe8 \ x8b \ xa6 \ xe7 \ x9f \ xad \ xef \ xbc \ x8c \ xe6 \ x88 \ x91 \ xe7 \ x94 \ xa8python'
Life is short, I with python

 

Guess you like

Origin www.cnblogs.com/python1988/p/12121778.html