🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.python
Article #27522

Re: String, unicode, dziwny problem i 5 pytań - długie

#27522
From: Gallus Anonimus
Date: Fri, 18 Jun 2010 13:29
34 lines
1855 bytes
On Wed, 16 Jun 2010 21:30:09 +0200, "Piotr Pastuszka"
<piotr.pastuszka@wp.pl> wrote:

>"
>#-*- coding:utf-8 -*-
>print ("Gotówka  wysłane")
>"


Reszty teraz nie przeczytam, ale tak na szybko to tu masz buraka w tym
kodzie. Powinno być tak:

#-*- coding:utf-8 -*-

print  u"Gotówka  wysłane"

Czyli tekst będzie interpretowany jako unikodowy (literka u przed
cudzysłwem)

Tylko że na wyjście będzie wysyłany unicod a wyświetlanie unicodu w
konsoli to na unixie, a w windzie niet. Dlatego może wywalić enkoding
error. Dlatego na windzie robisz tak:

#-*- coding:utf-8 -*-

print  u"Gotówka  wysłane".encode('cp1250')

a wszędzie w kodzie przy tekstach użwyasz u"....", czyli:

a = u"Łączka zajączka"

Możesz też próbować przestawić kodowanie ogólnie dla całego pythona,
ale w to mi się nie chce nigdy bawić, bo to jakaś zamotana sprawa
jest.
Technical Details
Message-ID: <josm16dm3smbi6qaunicp4ofioo9nogc1r@4ax.com>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!nf1.ipartners.pl!ipartners.pl!news.nask.pl!news.nask.org.pl!news.task.gda.pl!news.amu.edu.pl!news.man.poznan.pl!not-for-mail
References: <hvb8o0$roo$1@node2.news.atman.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!nf1.ipartners.pl!ipartners.pl!news.nask.pl!news.nask.org.pl!news.task.gda.pl!news.amu.edu.pl!news.man.poznan.pl!not-for-mail
From: Gallus Anonimus <gallusnnms@na_gmailu.com>
Newsgroups: pl.comp.lang.python
Subject: Re: String, unicode, dziwny problem i 5 pytań -
 długie
Date: Fri, 18 Jun 2010 15:29:19 +0200
Organization: POZMAN - http://www.man.poznan.pl/
Lines: 36
Message-ID: <josm16dm3smbi6qaunicp4ofioo9nogc1r@4ax.com>
References: <hvb8o0$roo$1@node2.news.atman.pl>
NNTP-Posting-Host: albedosrv.albedomarketing.pl
Mime-Version: 1.0
X-Trace: sunflower.man.poznan.pl 1276867760 594 194.114.146.146 (18 Jun 2010 13:29:20 GMT)
X-Complaints-To: tomjab@man.poznan.pl
NNTP-Posting-Date: Fri, 18 Jun 2010 13:29:20 +0000 (UTC)
X-Newsreader: Forte Agent 1.93/32.576 English (American)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit