pythonencodingbase64

Is there an easy way to represent the base64 alphabet in a Python list?


The alphabet (and its indices) can be found here:

http://www.garykessler.net/library/base64.html

Is there a shorter way than alphabet = ['A','B',...] of representing this alphabet?


Solution

  • You can use the string module

    import string
    alphabet = string.ascii_uppercase + string.ascii_lowercase + string.digits + '+/'