How to encode html and xml tag datas with standard python modules ?

DurumDara durumdara at gmail.com
Wed May 3 03:53:39 EDT 2006


Hi !

Have the python standard mod. lib. a html/xml encoder functions/procedures ?

like this:

def ToSafeHTM(Text):
    s=ToHuStrSafe(Text)
    l=[]
    for c in s:
        b=ord(c)
        if c=="\n":
            c="<br>"
        else:
            if b<32 or b>127 or c in ['<','>','"',';','&','@','%','#']:
                c="&#%03d;"%b
        l.append(c)
    s="".join(l)
    return s

Thanx for help:
    dd



More information about the Python-list mailing list