Τη Δευτέρα, 10 Ιουνίου 2013 11:15:38 π.μ. UTC+3, ο χρήστης Andreas Perstinger
έγραψε:
What is the difference between len('nikos') and len(b'nikos')
First beeing the length of string nikos in characters while the second being
the length of an ???
> The python interpreter will represent all values below 256 as ASCII
> characters if they are printable:
> >>> ord(b'a')
> 97
> >>> hex(97)
> '0x61'
> >>> b'\x61' == b'a'
> True
> The Python designers have decided to use b'a' instead of b'\x61'.
b'a' and b'\x61' are the bytestrings of char 'a' after utf-8 encoding?
This ord(b'a' )should give an error in my opinion:
ord('a') should return the ordinal value of char 'a', not ord(b'a')
--
http://mail.python.org/mailman/listinfo/python-list