在函数python中传递带冒号的变量

Moh*_*hit 4 python bulbs

我正在使用这个api ..其函数调用如下:

g.vertices.index.lookup(identifier="value")
Run Code Online (Sandbox Code Playgroud)

现在请注意,idenitifier是一个我尚未定义但由api解析的变量,value是一个字符串.

类似的事情发生在pymongo api:http://api.mongodb.org/python/current/tutorial.html

db = client.test_database
Run Code Online (Sandbox Code Playgroud)

等于

db = client["test_database"]
Run Code Online (Sandbox Code Playgroud)

test_database在第一种情况下,即使用户没有定义该变量..但mongo可以理解,在我的数据存储区中,我是否有一个名为test_database的数据库.

现在,我遇到的问题是:我的数据存储区中有一个冒号..

这就是说:

g.vertices.index.lookup(bad:identifier="value")
Run Code Online (Sandbox Code Playgroud)

请参阅查询中的冒号..

而这个api没有那个mongo类型的字典实现..

我知道,我应该解决这个问题,为什么我会得到这个结肠..但这就是我现在所困扰的......

问题是因为结肠,我得到了

g.vertices.index.lookup(bad:identifier="value")
                           ^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题

Jor*_*ley 8

g.vertices.index.lookup(**{"bad:identifier":"value"})
Run Code Online (Sandbox Code Playgroud)

可以工作...这被称为解包关键字参数