I’m a little confused. In Python what is the difference between a binary string, byte string, unicode string and a plain old string (str)? I’m using Python 2.6.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It depends on the version on Python you are using.
In Python 2.x if you write
'abc'it has typestrbut this means a byte string. If you want a Unicode string you must writeu'abc'.In Python 3.x if you write
'abc'it still has typestrbut now this means that is a string of Unicode characters. If you want a byte string you must writeb'abc'. It is not allowed to writeu'abc'.