lundi 23 mars 2015

remix function with using loop?

I have written 2 functions for my teammate to receive cisco devices commands. But now my teammate wants me to remix these two functions into one. But I had no idea to write a complete if statement. Am I going to write a if statement or loops? Please teach me what to do and thank you so much.



# def readrouter(x):
# conn = sqlite3.connect('server.db')
# cur = conn.cursor()
# cur.execute("SELECT DISTINCT command FROM router WHERE function =? or function='configure terminal' or function='enable' ORDER BY key ASC",(x,))
# read = cur.fetchall()
# return read;
#
# a = raw_input("x:")
# for result in readrouter(a):
# print (result[0])

def readswitch(x):
conn = sqlite3.connect('server.db')
cur = conn.cursor()
cur.execute("SELECT DISTINCT command FROM switch WHERE function =? or function='configure terminal' or function='enable' ORDER BY key ASC",(x,))
read = cur.fetchall()
return read;

a = input("x:")
for result in readswitch(a):
print (result[0])

Aucun commentaire:

Enregistrer un commentaire