vendredi 3 juillet 2020

How to generate random character from more than one source in Python?

I'm trying to generate some random characters but I want to include string.letters, string.digits, and string.punctuation. I can do any one of them, but how to include all three (or additional) sources/constants?

import random
import string

for i in range(0,4):
    print(random.choice(string.ascii_letters))

This code will choose a letter - would like to include digits and punctuation symbols also...




Aucun commentaire:

Enregistrer un commentaire