newformat format change
Martin Pool
martinpool at gmail.com
Wed Oct 5 14:31:51 BST 2005
On 05/10/05, Alexander Belchenko <bialix at ukr.net> wrote:
> John A Meinel пишет:
> > Actually, you need slightly better than .encode('utf-8') because you
> > also have to worry about escaping some characters, but that is a simple:
> >
> > ..replace('&', '&').replace('<', '<')...
> > Or you could keep a table, and go once over the string, replacing what
> > was appropriate. There is also python's translate functionality, but I
> > don't know if it lets you replace a single character with more than 1
> > character.
>
> Unicode strings have method '.translate' that very very powerful. It can
> be used for this job.
Interesting: it's quite different to str.translate, and can translate
characters to strings, which str.translate cannot.
--
Martin
More information about the bazaar
mailing list