Diskuze: Scrip pro přihlašovací údaje
Zobrazeno 5 zpráv z 5.
Dělá to přesně to, co jsi napsal.
u_pass in user_pass.get(user):
u_pass in user_pass.get(user) kdyz zadas jako heslo 'he',
tak ten zapis bude prelozen nejak takto:
'he' in 'heslo' a to je v pythonu pravda, dokonce by ti stacilo zadat libovolne
pismeno z hesla nebo nezadat nic.
V tomto pripade musis pouzit == pro porovnani retezcu a ne
in.
Jinak k heslu ze slovniku muzes pristoupit i takto
user_pass[user]
Slo by to i takto:
import sys
users = {'jmeno': 'heslo'}
attemps = 3
for i in range(attemps):
user = input('User name: ')
password = input('Password: ')
if user in users and password == users[user]:
print('access allowed')
break
print('wrong credentials')
else:
print('Too many wrong attempts')
sys.exit()
print('ur here')
Díky za pomoc. Má příkaz sys.exit() v tomhle případě nějaký benefit oproti quit()?
Tady je celkem pekne vysvetlene
Python exit commands - why so many and when should each be
used?
Zobrazeno 5 zpráv z 5.