Bonjour,
Je suis débutant en python 2.7 avec Tkinter.
Dans mon code, j'ai une erreur et je ne trouve pas la raison.
Code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 def controle(zz): if zz.count(" ")!=0: return zz.index(" ") else: return len(zz) def changeContact(): # Extraire chaque mot dune chaine de caractères maChaine = combo_destinataire.get() esp = cdc.count(" ") deb = 0 fin = controle(cdc) maListe = [] for i in range(0, esp + 1): maListe.append(cdc[deb:fin]) cdc=cdc[fin+1:] fin = controle(cdc) for j in range(len(maListe)): print(maListe[j]) print(maListe) civilite_destinataire = maListe[1] nom_destinataire = maListe[2] prenom_destinataire = maListe[3] telephone_destinataire = maListe[4] cle_identification_destinataire = maListe[5] print "\nVerification :" print maListe[1] print maListe[2] print maListe[3] print maListe[4] print maListe[5]
Retour console
D'ou vient l'erreur ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 <type 'exceptions.UnboundLocalError'> Exception in Tk callback Function: <function changeLabel at 0x7f2014f06ed8> (type: <type 'function'>) Args: () Traceback (innermost last): File "/usr/lib/python2.7/dist-packages/Pmw/Pmw_1_3/lib/PmwBase.py", line 1747, in __call__ return apply(self.func, args) File "test_15.py", line 2302, in changeContact esp = cdc.count(" ") <type 'exceptions.UnboundLocalError'>: local variable 'cdc' referenced before assignment
Merci.
Partager