import mysql.connector def valid (s): if s=='' or len(s)==0: return False if s.count('@')!=1: return False if s.count('.')!=1: return False t=s.index('@') p=s.index('.') f=s[:t] m=s[t+1:p] l=s[p+1:] if f.isalnum() and m.isalpha() and l.isalpha(): return True else: return False databasename='shotor' cnx= mysql.connector.connect(user='root',password='', host='127.0.0.1', database=databasename) cursor=cnx.cursor() tablename='data' #cursor.execute('CREATE table %s (username varchar(20), password varchar(20));'%tablename) #cnx.commit() username='?' password='?' s=input() while valid(s)==False: print('please enter a valid email address like this: username@something.something') s=input() username=s s=input() while s.isalnum()==False: print('password can only contain alphabet and digits') s=input() password=s cursor.execute('INSERT INTO %s VALUES(\'%s\',\'%s\')'%(tablename,username,password)) cnx.commit() cnx.close()
bash برای rename کردن زیرنویس ها
s ,false ,password ,return ,cnx ,input ,return false ,s input ,if s ,username password ,s count
درباره این سایت