Rumah > Artikel > pembangunan bahagian belakang > Python变长参数
感觉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])