我找不到似乎已经发布在堆栈中的类似消息,所以这里举一个简短的例子:
# Current Code
dbCon = pyodbc.connect(sCon, autocommit=True)
# Future/Desired pseudo code
vAutocommit = {'autocommit': True}
dbCon = pyodbc.connect(sCon, vAutocommit)
我确定我缺少一个简单的python概念,因此请原谅此语言的更新。谢谢。
答案 0 :(得分:1)
您可以通过字典并将其解压缩为kwarg
:
# Current Code
dbCon = pyodbc.connect(sCon, autocommit=True)
# Future/Desired pseudo code
vAutocommit = {'autocommit': True}
dbCon = pyodbc.connect(sCon, **vAutocommit) <<< the ** unpacks the
dictionary's key/value
pairs as arguments.