python encoding base-64 and uu

It is just the inverse of the original function....

Let me try and show you. I will use 2 common encoding type uu and base-64.

Python 3

    from codecs import decode,encode
    import uu

    orig="Cat"
    encoding_types=['uu','base-64']
    for et in encoding_types:
        enc_data=encode(orig.encode(),et)
        un_enc_data=decode(enc_data,et)
        print("\n\nEncoding  : {}".format(et))
        print("Orig          : {}".format(orig))
        print("Encoded       : {}".format(enc_data))
        print("byte UnEncoded: {}".format(un_enc_data))
        print("utf8 UnEncoded: {}".format(un_enc_data.decode()))

This should output

Encoding  : uu
Orig          : Cat
Encoded       : b'begin 666 <data>\n#0V%T\n \nend\n'
byte UnEncoded: b'Cat'
utf8 UnEncoded: Cat


Encoding  : base-64
Orig          : Cat
Encoded       : b'Q2F0\n'
byte UnEncoded: b'Cat'
utf8 UnEncoded: Cat

We need the final .decode() as we initially converted the str data object into bytes with the encode().