Python变长参数
程序员文章站
2022-03-25 19:43:56
...
感觉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])
上一篇: PHP中大括号'{}'用法图文详解
下一篇: nginx反向代理机制解决前端跨域问题