Python use command word in the function -
i new in python.
this part of python web service(flask) code.
the function login uses command parameter,however; don't see other classes call login function.
my question : command here?
import mysqldb mydb def login(command): command = command[1:] command = command[:-1] command = command[15:] = 0 while command[i] != ',': = + 1 username = command[:i - 1] command = command[i + 17:] = 0 while command[i] != ',': = + 1 password = command[:i - 1] return queryuser(username, password) def queryuser(username, password): sdb = mydb.connect(host='127.0.0.1',user='root',passwd='1',db='testdb') query = sdb.cursor() query.execute("""select user_id user_info user_id = %s , user_password = %s""", (username,password,)) if query.fetchone() not none: query.close() sdb.close() return 'true' else: query.close() sdb.close() return 'false: invalid username , password'
my guess function imported module somewhere else in code base (or possibly flask automatically). code horribly unpythonic can tell, command
string contains username , password, separated comma this:
login('????????????????awd,?????????????????1234cats,?????') → queryuser('awd', '1234cats')
Comments
Post a Comment