Sera lista in attesa dei risultati elettorali stavo provando le regex con python, ho fatto una semplice funzione che determina se la password contiene tutti gli elementi necessari. Se uso if e i vari elif a seguire funziona tutto ho provato a compattare usando gli and ma dopo il primo controllo termina la verifica , dove sbaglio? Grazie e buona serata
Silvestro Di seguito il codice: import re def control_pwd(password): lunPwd = len(password) numPwd = re.compile(r'\d+') letUpPwd = re.compile(r'[A-Z]+') letDwPwd = re.compile(r'[a-z]+') chrPwd = re.compile(r'\\|-|@|_|\?') testNumPwd = numPwd.search(password) testLetUpPwd = letUpPwd.search(password) testLetDwPwd = letDwPwd.search(password) testChrPwd = chrPwd.search(password) #print (str(lunPwd) + ' ' + str(testNumPwd) + ' ' + str(testLetUpPwd) + ' ' + str(testLetDwPwd) + ' ' + str(testChrPwd)) if lunPwd < 8 and testNumPwd is None and testLetUpPwd is None and testLetDwPwd is None and testChrPwd is None: print('''La password deve essere lunga almeno 8 caratteri ,composta da lettere maiuscole e minuscole, numeri e carattteri speciali: \ , _ , @ , - ''') else: print('password robusta') print('Inserisci password') pwd = input() control_pwd(pwd)
_______________________________________________ Python mailing list Python@lists.python.it https://lists.python.it/mailman/listinfo/python