BlackJack hat geschrieben: Ich habe immer noch nicht verstanden welches *Problem* Du eigentlich lösen willst‽
Keine Ahnung, welches Problem ich hab:
Code: Alles auswählen
Python 2.7.5+ (default, Sep 17 2013, 15:31:50)
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> f = open('bla', 'wb')
>>> json.dump(u'ä', f, ensure_ascii=False)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/json/__init__.py", line 190, in dump
fp.write(chunk)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 1: ordinal not in range(128)
Code: Alles auswählen
Python 3.3.3 (default, Nov 27 2013, 17:12:35)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> f = open('bla', 'wb')
>>> json.dump(u'ä', f, ensure_ascii=False)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.3/json/__init__.py", line 184, in dump
fp.write(chunk)
TypeError: 'str' does not support the buffer interface
mutetella