【发布时间】:2017-12-13 02:38:57
【问题描述】:
我无法处理在 python **kwargs 中传递可选参数
def ExecuteyourQuery(self, queryStatement, *args, **kwargs):
if self.cursorOBJ is not None:
resultOBJ = self.cursorOBJ.execute(queryStatement, *args,**kwargs)
self.resultsVal = resultOBJ.fetchall()
当我调用函数时,下面的语句可以正常工作
ExecuteyourQuery('select * from item_table where x = :x and y:y', x, y)
但是当我给出一个查询中没有提到的额外参数时,比如
ExecuteyourQuery('select * from item_table where x = :x and y:y', x, y, z)
它返回 0 作为输出
【问题讨论】:
-
我不太确定您提出的查询?带有“y”的条件是否符合预期?
-
“以下语句工作正常......”是什么意思?没有通过 z 时返回什么?如上所述,'y' 的“和”条件是否符合预期(和 y:y)?
标签: python sql python-3.x python-2.7 cx-oracle