Skip to content

Instantly share code, notes, and snippets.

@selimnairb
selimnairb / base36.py
Last active June 25, 2020 02:36 — forked from marcg1968/base36.py
Python convert (encode/decode) base 36
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# http://stackoverflow.com/a/1181922
def base36encode(number, alphabet='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'):
"""Converts an integer to a base36 string."""
if not isinstance(number, int):
raise TypeError('number must be an integer')