Article View: pl.comp.lang.python
Article #15831translacja tekstu na czysty zbiów lower(ascii+digit+plfonts)
From: meloites
Date: Mon, 19 Jun 2006 08:25
Date: Mon, 19 Jun 2006 08:25
28 lines
1969 bytes
1969 bytes
witam
Szukam pomocy w skrypcie translacji plików tekstowych na format litery +
cyfry + polskie litery+spacje z pominięciem wszytkich pozostałych znaków.
Mam taki kod:
---------------------------------------------------
class Keeper(object):
def __init__(self, keep):
self.keep = sets.Set(map(ord, keep))
def __getitem__(self, n):
if n not in self.keep:
return None
return unichr(n)
def __call__(self, s):
return s.translate(self)
makefilter = Keeper
if __name__ == '__main__':
just_vowels = makefilter('abcdefghijklmnopqrstuvwxyz1234567890ąśżćźłóńę
')
------------------------------------------------------
a potem wywołanie :
print just_vowels(u"s")
i to działa i ładnie wyświetla przefiltrowane teksty ale jeśli chcę to
wrzucić do zmiennej to już mi się blokuje, coś nie tak ze zmiennymi jest :
s = just_vowels(s)
TypeError: expected a character buffer object
czy ktoś mógłby pomóc?
m.
Technical Details
Message-ID:
<e75n04$28v$1@news.interia.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!mat.uni.torun.pl!news.man.torun.pl!newsfeed.pionier.net.pl!news.nask.pl!news.nask.org.pl!news.cyf-kr.edu.pl!feed.news.interia.pl!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!mat.uni.torun.pl!news.man.torun.pl!newsfeed.pionier.net.pl!news.nask.pl!news.nask.org.pl!news.cyf-kr.edu.pl!feed.news.interia.pl!not-for-mail From: "meloites" <seper@poczta.fm> Newsgroups: pl.comp.lang.python Subject: translacja tekstu na czysty zbiów lower(ascii+digit+plfonts) Date: Mon, 19 Jun 2006 10:25:11 +0200 Organization: INTERIA.PL S.A. Lines: 30 Message-ID: <e75n04$28v$1@news.interia.pl> NNTP-Posting-Host: aif102.internetdsl.tpnet.pl X-Trace: news.interia.pl 1150705476 2335 83.16.213.102 (19 Jun 2006 08:24:36 GMT) X-Complaints-To: usenet@news.interia.pl NNTP-Posting-Date: Mon, 19 Jun 2006 08:24:36 +0000 (UTC) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 X-Newsreader: Microsoft Outlook Express 6.00.2800.1807 X-Priority: 3 X-Authenticated-User: seper % poczta+fm X-MSMail-Priority: Normal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit