string - What's the relationship between str and bytes in python? -


consider following typescript:

>>> s = 'a' >>> isinstance(s, bytes) true >>> isinstance(s, str) true >>> isinstance(s, unicode) false >>> isinstance(s.decode('utf-8'), unicode) true 

how come s both str , bytes? 1 of descendant of other one?

how did run it? trying find description of decode method in docs. couldn't find str, able bytes.

you looking @ wrong documentation.

this equivalence true in python 2.7. there, bytes introduced alias str in order ease migration python 3.

in python 3, str called unicode, bytes type called str.

the documentation str.decode python 2 here.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -