i found “locals” which could meet my needs:
getVar = locals()
a1 = "a1"
a2 = "a2"
a3 = "a3"
bb1 = [a1,a2]
bb2 = [a1,a2,a3]
all_sql = [bb1,bb2]
for one in all_sql:
db_values = ",".join([str([getVar[i]) for i in all_sql])
db.exec_insert(db_values)
my unclear expression and poor English may troubled others 🙁
solved Python: is there a common way to simplify the code which used in sql