newformat format change
Alexander Belchenko
bialix at ukr.net
Wed Oct 5 11:02:11 BST 2005
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.
Alexander.
More information about the bazaar
mailing list