Articles tagués “generation

Python is beautiful

L’autre jour, j’utilisais Python pour des tests de réseaux et j’avais besoin de générer des données aléatoires pour des envois en masse. J’ai encore une fois eu la preuve que Python is beautiful et que Stackoverflow est indispensable.

Simple. Efficace. Aperçu :

>>> import string
>>> import random
>>> choices = string.ascii_uppercase + string.ascii_lowercase + string.digits
>>> choices
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
>>> ''.join(random.choice(choices) for c in range(42))
'9fEsWeZBYx2VKwcBipnrcznOZlHoO7Bp4lVeLbYPZE'
>>> ''.join(random.choice(choices) for c in range(242))
'oYgn3yM2dUQe2kPIB3PVgZKAo7wvoJZPbUy6dCR2lWRMhe4vKl12PWpsBpoHDnWPP01ga5hn
A01AzDW9GWJPwfLZZ1I3hA0fIsNkYSy2UeKETZOSZ1EnCJVl5DtJBGqmO3Gp50U1xDoIjdVQG
NcQ3PIWY7XLDxUgq4r2Ikla3ccVVJWIa8elSKMkFhafcGRIQktn2pqmjMw5prj06UM6eJLSL8
xIrKYAyKQllLShAZMs1LPswH'

Python


Concevoir un site comme celui-ci avec WordPress.com
Commencer