[Python-de] Problem bei Ausgabe von Unicode-Strings

Andreas Jung lists at zopyx.com
Mo Sep 22 13:13:00 CEST 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

https://docs.python.org/2/howto/unicode.html

Harald Wenninger wrote:
> Hallo zusammen,
> 
> ich habe ein Problemchen bei der Ausgabe von Unicode-Strings.
> 
> folgendes Progrämmchen: ----------------------- #!/usr/bin/python2.7 
> # encoding: utf-8
> 
> print u'ä' -----------------------
> 
> funktioniert wunderbar, wenn es einfach so aufgerufen wird: $
> ./test.py ä $
> 
> tut aber nicht mehr, wenn man die Ausgabe umleitet: $ ./test.py >
> test.txt Traceback (most recent call last): File "./test.py", line 4,
> in <module> print u'ä' UnicodeEncodeError: 'ascii' codec can't encode
> character u'\xe4' in position 0: ordinal not in range(128) $
> 
> Das print-Statement scheint Probleme zu haben, einen Unicode-String 
> korrekt auszugeben. Wie schaffe ich das?
> 
> Gruß, Harald _______________________________________________ 
> python-de maillist  -  python-de at python.org 
> https://mail.python.org/mailman/listinfo/python-de


- -- 
Regards
Andreas Jung
andreas at andreas-jung.com
about.me/andreasjung
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQGUBAEBAgAGBQJUIAQ8AAoJEADcfz7u4AZjD8ILwMnAzzQC/0VDbgAWPFYptlIl
KnQFqXDHCIoSV0iH+pbRvP8rRBLMEw1nt4nVzSJB4hkNyVswmZquHbsZZfmXs8MP
/yMzVl+n2GsvR6vGAEqdAFiss5sQiZccMZt5APtDzDZ2Yp3rebTz8owna1PI9cZS
2M/Wp4ccyz44xwsRZvTjZ+NkOBO7j9f0R2ZApewI9wErZcu/V69zS7wyevqDkQPf
ZMdqBESfNddEPQZ6Lg/UBjD2+xNXoYw1DstrDwLL0jwQV6C41e7CpJCLkTsAgNmL
52Sul/uibNM0IICHX/B6/SzBhxscqn+lH77q8aTlyzMtff0hDTzy1C1+Qw1Nnyx6
lfcjABLZesKoWgNjjEY64PTks1tI0vcPIy5k1pli4tsIq/nlT4I9mAuCA0e8cxvL
vGVraW23STMSk0z3S4/GHAps+BdigCMvdw6DD+H+A3yb4HUKGNo/uQZ3UsxaLpz5
TZgqFNF4ePRNRifQtmX67+i9sgFYtWY=
=vUKc
-----END PGP SIGNATURE-----


Mehr Informationen über die Mailingliste python-de