# str vs bytes

'string' # type: str

b'string' # type: 


string = 'string'

string # output: 'string'

type(string) # output: str


# str to bytes (encode str obj to utf-8 bytes)

bstr = string.encode()

type(bstr) # output: bytes


# bytes to str (decode utf-8 bytes to str obj)

bstr.decode() # output: utf-8

bstr.decode('utf-16') # output: utf-16



WRITTEN BY
hojongs
블로그 옮겼습니다 https://hojongs.github.io/