os.system: string encoding

Peter Kleiweg p.c.j.kleiweg at rug.nl
Sun Jun 27 16:17:52 EDT 2010


Martin v. Loewis schreef op de 27e dag van de zomermaand van het jaar 2010:

> Am 25.06.2010 17:13, schrieb Peter Kleiweg:
> > How do I set the string encoding for os.system to anything other then UTF-8?
> 
> You shouldn't have to set it, as it should use your locale's encoding.
> In 3.1.2, it will.
> 
> For the moment, you can encode the string explicitly, and pass a byte
> string.

That doesn't work

    Python 3.1.1 (r311:74480, Oct  2 2009, 11:50:52) 
    >>> import os
    >>> os.system('echo \N{EURO SIGN}'.encode('iso-8859-15'))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: must be string, not bytes


-- 
Peter Kleiweg  L:NL,af,da,de,en,ia,nds,no,sv,(fr,it)  S:NL,de,en,(da,ia)
info: http://www.let.rug.nl/kleiweg/ls.html



More information about the Python-list mailing list