Python变长参数
程序员文章站
2022-04-17 09:42:14
...
感觉Python的变长参数还是蛮好用的,记录下,便于查询。
def selectsql(self, sqlstr, *condition):
arr = sqlstr.split("?")
if len(arr) != len(condition) + 1:
return
rs = ""
for i in range(len(arr)-1):
rs += arr[i] + str(condition[i])
print(rs)
def sele(self,sqlstr,**condition):
for key in condition:
print(key,condition[key])
def selectsql(self, sqlstr, *condition):
arr = sqlstr.split("?")
if len(arr) != len(condition) + 1:
return
rs = ""
for i in range(len(arr)-1):
rs += arr[i] + str(condition[i])
print(rs)
def sele(self,sqlstr,**condition):
for key in condition:
print(key,condition[key])
上一篇: mysql中实现七表查询实例(二)