Outils pour utilisateurs

Outils du site


python

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

python [2012/12/05 23:56]
mart suite aléatoire
python [2019/04/02 11:14]
Ligne 1: Ligne 1:
-====== Python ====== 
  
-//Cette page contient une série de bouts de code que j'ai envie de partager et surtout pouvoir retomber dessus quand j'en aurai besoin. Oui je sais c'est égoïste.//​ 
- 
-Le code est en général prévu pour python 3. 
- 
-=== string === 
- 
-[[http://​docs.python.org/​3.4/​library/​string.html|doc]] 
- 
-<​code>>>>​ import string 
->>>​ string.printable 
-'​0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#​$%&​\'​()*+,​-./:;<​=>?​@[\\]^_`{|}~ \t\n\r\x0b\x0c'​ 
->>>​ string.ascii_letters 
-'​abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'​ 
->>>​ string.whitespace 
-' \t\n\r\x0b\x0c'​ 
->>>​ string.hexdigits 
-'​0123456789abcdefABCDEF'</​code>​ 
- 
-=== génération suite aléatoire === 
- 
-Au cas où l'on a besoin de générer rapidement une longue suite de caractères (style génération de mot de passe) 
- 
-<​code>​import string 
-import random 
- 
-key1 = ''​.join(random.choice(string.printable) for i in range(20)) 
-key2 = ''​.join(random.choice(string.digits+string.ascii_lowercase) for i in range(20)) 
-# ex: key1 = '​)\t3,​g*PR\x0cP)L=8U;,"​4@'​ 
-# ex: key2 = '​7vcl5ojai1yjmsaar4jd'</​code>​ 
python.txt · Dernière modification: 2019/04/02 11:14 (modification externe)