Generate a random string from [a-z0-9] in Python.
Read the documentation of random module in Python Standard Library is enough
for implementation. random.choice is exactly the function we need to randomly
pick up letter from alphabet.
#!/usr/bin/env python# -*- coding:utf-8 -*-importrandomALPHABET="abcdefghijklmnopqrstuvwxyz0123456789"defrandom_string(strlen):result=""foriinrange(strlen):result+=random.choice(ALPHABET)returnresultif__name__=='__main__':# for test purposerandom.seed()print(random_string(5))print(random_string(6))print(random_string(7))