Article View: pl.comp.lang.python
Article #27104Re: Kodowanie stringu pod windows i linux
From: Gallus Anonimus
Date: Wed, 23 Dec 2009 08:36
Date: Wed, 23 Dec 2009 08:36
16 lines
1411 bytes
1411 bytes
On Tue, 22 Dec 2009 22:58:48 -0800 (PST), Michal M
<mmierzwa@tycowaterworks.pl> wrote:
>Czyli muszę dodać u" mimo, iż napis jest w unicode. Ok, a jak to
>zrobić ze stringami wczytywanymi z pliku?
>Nie mogę dodać 'u' przed nazwą zmiennej raczej.
tak?
import codecs
f = codecs.open("plik.txt","r","utf-8")
txt = f.read()
f.close()
print type(txt)
print txt.encode('windows-1250')
Technical Details
Message-ID:
<sdl3j59muoire1dn8qhohhld9e8u98pfid@4ax.com>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.man.poznan.pl!not-for-mailReferences:
<f20bf1d1-7b95-4134-8480-402e8cf72630@a32g2000yqm.googlegroups.com> <d38ff7b6-eef8-4952-a1c8-183d3b9e432d@v13g2000yqk.googlegroups.com> <7d25fecc-0503-401e-aa9c-ca2764689842@d10g2000yqh.googlegroups.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.man.poznan.pl!not-for-mail From: Gallus Anonimus <gallusnnms@na_gmailu.com> Newsgroups: pl.comp.lang.python Subject: Re: Kodowanie stringu pod windows i linux Date: Wed, 23 Dec 2009 09:36:21 +0100 Organization: POZMAN - http://www.man.poznan.pl/ Lines: 19 Message-ID: <sdl3j59muoire1dn8qhohhld9e8u98pfid@4ax.com> References: <f20bf1d1-7b95-4134-8480-402e8cf72630@a32g2000yqm.googlegroups.com> <d38ff7b6-eef8-4952-a1c8-183d3b9e432d@v13g2000yqk.googlegroups.com> <7d25fecc-0503-401e-aa9c-ca2764689842@d10g2000yqh.googlegroups.com> NNTP-Posting-Host: albedosrv.albedomarketing.pl Mime-Version: 1.0 X-Trace: sunflower.man.poznan.pl 1261557381 29140 194.114.146.146 (23 Dec 2009 08:36:21 GMT) X-Complaints-To: tomjab@man.poznan.pl NNTP-Posting-Date: Wed, 23 Dec 2009 08:36:21 +0000 (UTC) X-Newsreader: Forte Agent 1.93/32.576 English (American) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit