# 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
'Language > python' 카테고리의 다른 글
[python] beautifulsoup4 example (0) | 2017.11.26 |
---|---|
[python] get html (urlopen) best way (0) | 2017.11.26 |
[python] json example (0) | 2017.11.25 |
[python] Windows python3, jupyter 설치하기 (0) | 2017.11.25 |
[python] 장점, 써야하는 이유 / 프로그래밍언어 비교 (0) | 2017.11.25 |
WRITTEN BY
- hojongs
블로그 옮겼습니다 https://hojongs.github.io/