I gett following different result when using these two Class.
>>> import StringIO
>>> import cStringIO
>>> StringIO.StringIO().write(u'\u2222')
>>> cStringIO.StringIO().write(u'\u2222')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2222' in position 0: ordinal not in range(128)
The root cause is explained on document for cStringIO
Unlike the StringIO module, this module is not able to accept Unicode strings that cannot be encoded as plain ASCII strings.
原始链接:http://xcodest.me/python-cstring-unicode.html
许可协议:"署名-非商用-相同方式共享 3.0" 转载请保留原文链接及作者。
Comments