前言:
现时你们对“pythonexecute函数”大致比较关怀,我们都需要剖析一些“pythonexecute函数”的相关知识。那么小编同时在网络上收集了一些有关“pythonexecute函数””的相关知识,希望兄弟们能喜欢,大家一起来了解一下吧!以前学python的时候,看案例都是传一个参数的,如:
cur2.execute("update ris.orders set patient_age= 27 where patient_id='%s' ",study_data[0])
当用到需要两个参数的时候,自以为是这样写,如下:
cur2.execute("update ris.orders set patient_age= %s where patient_id='%s' ",year_data[0],study_data[0])
此时,python 就提示错误:execute() takes from 2 to 3 positional arguments but 4 were given 中文翻译是:execute()接受2到3个位置参数,但给出了4个。
正确的语句是:
cur2.execute("update ris.orders set patient_age= %s where patient_id='%s' ",(year_data[0],study_data[0])),即多加一个括号。
标签: #pythonexecute函数 #pythonexecute