The type of data bytes Python 3

 

"" " 
B '\ XE6 \ X88 \ X91 \ XE7 \ X88 \ xb1Python \ XE7 \ XBC \ X96 \ XE7 \ xa8 \ x8b'
represent this byte is a channeling \ x represents the sixteen hexadecimal representation e6 decimal
"" "
# Create an empty bytes
B1 bytes = ()
Print (B1)

# of bytes to create a null value
B2 = b ''
Print (B2)

# hello specified by prefix bytes type b value
b3 = b'hello '
Print (B3)
Print (B3 [0])
Print (B3 [2:. 4])

# bytes method invocation string converted into bytes object
b4 = bytes (' I love Python programming ', encoding =' utf -8 ')
Print (B4)

# string using the encode () method of the object into byte code string (bytes), using the default utf-8 character set
b5 = "I love Python programming" .encode (' utf- . 8 ')
Print (B5)

# DNCODE using the byte string () method is decoded into byte string string (object)
ST = b5.decode (' UTF-. 8 ')
Print (ST)

Source: http://c.biancheng.net/view/2175.html

 

Guess you like

Origin www.cnblogs.com/yibeimingyue/p/11421956.html