看到區別:
$ python3
Python 3.1.3 (r313:86834, May 20 2011, 06:10:42)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> len('día') # Unicode text
3
>>>
$ python
Python 2.7.1 (r271:86832, May 20 2011, 17:19:04)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> len('día') # bytes
4
>>> len(u'día') # Unicode text
3
>>>
Python 3.1.3 (r313:86834, May 20 2011, 06:10:42)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> len(b'día')
File "<stdin>", line 1
SyntaxError: bytes can only contain ASCII literal characters.
>>> len(b'dia')
3
>>>
就這麼簡單' 「[0-9] I [+ - ]」' –
的Python 2.x或Python 3中? –
在Python 2.x中,rawData只是一些字節,但在Python 3中它將是Unicode文本。 –