Aug-09-2018, 10:59 AM
Hi, how can i get the value of each variable that i'm creating in my loop ? I have this :
for fichier in os.listdir("result/"):
if not fnmatch.fnmatch(fichier, 'file_0.txt'):
#récupération de valeur
with fileinput.input(["result/"+fichier], inplace=1) as file_X :
# file_X.write('\r\ncoucou')
print("------Récupération de variable-------")
for line in file_X:
balise02R = False
balise191Absente = True
line = line.strip('\n')
if line.startswith('/02/R'):
balise02R = True
sys.stderr.write("Balise 02 présente /02/R\r\n")
if line.startswith("/20/"):
splitLigne20 = line.split("/")
valeur20 = splitLigne20[2]
if line.startswith("/66/"):
splitLigne66 = line.split("/")
valeur66 = splitLigne66[2]
if line.startswith("/191/"):
balise191Absente = False
sys.stderr.write("Balise 191 présente\r\n")
print (line.rstrip('\n'))
# break
if balise02R == True and balise191Absente == True:
sys.stderr.write("balise 02 " + str(balise02R) + " / balise 191 " + str(balise191Absente) +"\r\n")
...But variable balise02R hasn't the right value (but it's indead equals to True in trace). I tried break, continue and pass but nothing, any advice ?
