メモ用サブブログ

子曰わく學びて時にこれを習う。

2014-02-26から1日間の記事一覧

Python2.7.x AsciiとUnicodeの組み合わせの挙動

>>> "test"+"a" 'testa' >>> "test"+u"2" u'test2' >>> "test"+u"あ" u'test\u3042' >>> "test{}".format(u"あ") Traceback (most recent call last): File "<stdin>", line 1, in <module> UnicodeEncodeError: 'ascii' codec can't encode character u'\u3042' in positio</module></stdin>…