Python ud Umlaute

Hallo, ich möchte aus einem QT EditLine einen TExt auslesen und in eine DB schreiben aber Python mekcert sobald Umlaute auftauchen print self.textEditComment.text() Der Fehler ist: UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 9: ordinal not in range(128) Wie kann ich den "umgehen" ? _______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de

--On 3. August 2005 15:13:27 +0200 Stefan Miefert <smiefert@kikxxl.de> wrote:
Hallo,
ich möchte aus einem QT EditLine einen TExt auslesen und in eine DB schreiben aber Python mekcert sobald Umlaute auftauchen
print self.textEditComment.text()
Der Fehler ist:
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 9: ordinal not in range(128)
Wie kann ich den "umgehen" ?
Wahrscheinlich liefert Dir text() eine Python Unicode String zurück. Du mußt die Ausgabe explizit in ein gewünschtes Encoding verwandeln. print someunicodestring.encode(encoding) # encoding='iso-8859-15' z.b. -aj _______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de

Hallo, * Stefan Miefert <smiefert@kikxxl.de>:
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 9: ordinal not in range(128)
Wie kann ich den "umgehen" ?
Lies mal http://p-nand-q.com/python/unicode_faq.html Dort wird ausführlich erklärt, warum sich Python so verhält und was zu tun ist. Lutz _______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Mach ganz einfach folgendes: print.self.textEditdComment.text().latin1() Gruß Gerhard - --------------- Stefan Miefert schrieb: | Hallo, | | | ich möchte aus einem QT EditLine einen TExt auslesen und in eine DB | schreiben aber Python mekcert sobald Umlaute auftauchen | | print self.textEditComment.text() | | Der Fehler ist: | | UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in | position 9: ordinal not in range(128) | | Wie kann ich den "umgehen" ? | | _______________________________________________ | python-de maillist - python-de@python.net | http://python.net/mailman/listinfo/python-de | - -- - ------------------------------------------------------ skequell ------ ~ Gerhard Quell Software & Knowledge Engineering ~ Postfach: 1314 eMail: gquell@skequell.de Fon: 08282-890631 ~ 86371 Krumbach web : http://www.skequell.de Fon: 0172-4057876 - ------- pgp: 473EC53C - http://math-www.uni-paderborn.de/pgp/ ------- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFC8Pb4vHbZD0c+xTwRApvGAKCR8geAYAAej6McLHApdNbeaGiATQCfXqW6 3tBdI8WKKpBs/K0DXQ2WX4Q= =ZQQr -----END PGP SIGNATURE----- _______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de
participants (4)
-
Andreas Jung
-
gerhard quell
-
Lutz Horn
-
Stefan Miefert