Skip to content

Instantly share code, notes, and snippets.

@rbarrois
Last active February 27, 2017 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbarrois/ee7af147030d288e0c8bfff754f0c64b to your computer and use it in GitHub Desktop.
Save rbarrois/ee7af147030d288e0c8bfff754f0c64b to your computer and use it in GitHub Desktop.
Support sur #python-fr, 20170227
# Pas besoin de point-virgule
import os;
# Utilise open("gaumont.generate.txt", 'w') à la place ; ici tu supprimes le fichier puis l'ouvres en mode "ajout à la fin",
# autant l'ouvrir directement en mode "remplacement"
os.remove("gaumont.generate.txt");
FILE = open("gaumont.generate.txt", "a+");
print("=========================");
print(" GAUMONT GENERATOR BY TCHOTCHO");
print("=========================");
print("[1] Explication");
print("[2] Généré");
print("");
CHOICE = str(input("Votre choix: "));
print("=========================");
def number(x):
# Tu peux remplacer cette fonction par :
return '%3d' % x
if x >= 0 and x <= 9:
# Pas besoin de parenthèses :
# return "00" + str(x) marche
return("00" + str(x));
if x >= 10 and x <= 99:
return("0" + str(x));
if x >= 100 and x <= 999:
return(str(x));
def number(l):
if x >= 0 and x <= 9:
return("0" + str(l));
if x >= 10 and x <= 99:
return(str(l));
# Pas la peinde de mettre les deux blocs imbriqués
# Tu peux faire :
# if CHOICE == "1":
# ...
# elif CHOICE == "2":
# Ton code
# else:
# print("Sélectionner parmi la liste")
#
if CHOICE == "1" or CHOICE == "2":
if CHOICE == "2":
print(" 14AA CXXX BBLL");
ALGO1 = str(input("14AA: "));
ALGO3 = str(input("C: "));
ALGO2 = str(input("BB: "));
print("=========================");
print(" GENERATION....");
print("=========================");
i = 0;
# À quoi sert cette ligne ? L != 1 n'effectue aucun calcul.
# L n'étant pas défini, ton code va crasher ici.
L != l;
while i < 999:
# Comme "number()" renvoie déjà du texte, tu n'as pas besoin de refaire str(number(...))
# La variable 'l' (L minuscule) n'existe pas dans ce contexte
FILE.write(ALGO1 + ALGO3 + str(number(i)) + ALGO2 + str(number(l)) + ":" + ALGO1 + ALGO3 + str(number(l)) + ALGO2 + str(number(l)) + '\n');
print(ALGO1 , ALGO3 , str(number(i)) , ALGO2 , str(number(l)));
i += 1;
else:
print("Selectionner parmit la liste");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment