Python变长参数
时间:2021-07-01 10:21:17
帮助过:57人阅读
感觉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])