samedi 31 juillet 2021

How do I not get whitespaces while generating a random string which should contain special characters in python?

I have been working on a password management system and need to auto-generate a password which should be alphanumeric and have special characters but no whitespaces.

password = ''.join(random.choice(string.ascii_letters + string.digits + string.printable) for _ in range(14))

But this causes some problems and also generates '\n' and ' ' Any way by which I can fix this? Or any other simple method to generate a string meeting the requirements? Thank you




Aucun commentaire:

Enregistrer un commentaire