Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # unicode => human readable format
- uni_text = u'café'
- print type(uni_text)
- print isinstance(uni_text, str)
- print len(uni_text)
- uni_str_convert = uni_text.encode('UTF-8')
- # str => bytes
- str_text = 'café'
- print type(str_text)
- print isinstance(str_text, unicode)
- print len(str_text)
- str_uni_convert = str_text.decode('UTF-8')
- # comparisons
- print uni_str_convert == uni_text
- print uni_str_convert == str_text
- print str_uni_convert == uni_text
- print str_uni_convert == str_text
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement