generating random passwords ... for a csv file with user details

andychambers2002 at yahoo.co.uk andychambers2002 at yahoo.co.uk
Sun May 28 04:21:25 EDT 2006


import random

def rand_str(len):
    chars = ''.join(['abcdefghijklmnopqrstuvwxyz',
                     'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
                     '1234567890',
                     '_+']) # plus whatever additional characters you
want
    return ''.join([random.choice(chars) for i in range(len)])

print rand_str(10)




More information about the Python-list mailing list