python - 如何在 Gremlin-Python 中使用“neq”?
问题描述
我有一个Gremlin 查询,可以在 Gremlin 控制台上使用
g.V("p1").as("this").out("ContributedTo").in("ContributedTo").where(neq("this")).groupCount()
我想从 Python 脚本中使用它
from __future__ import print_function # Python 2/3 compatibility
from gremlin_python import statics
from gremlin_python.structure.graph import Graph
from gremlin_python.process.graph_traversal import __
from gremlin_python.process.strategies import *
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
graph = Graph()
g = graph.traversal().withRemote(DriverRemoteConnection('wss://neptunedbcluster.neptune.amazonaws.com:8182/gremlin','g'))
g.V('p1').as_('this').out('ContributedTo').in_('ContributedTo').where(__.neq('this')).groupCount()
我得到一个错误:
AttributeError: type object '__' has no attribute 'neq'
我应该如何在 Python 中表达 Gremlin 'neq'?
解决方案
neq
是P
类的一部分,所以我应该导入它并使用它
from __future__ import print_function # Python 2/3 compatibility
from gremlin_python import statics
from gremlin_python.structure.graph import Graph
from gremlin_python.process.graph_traversal import __
from gremlin_python.process.traversal import P
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
graph = Graph()
g = graph.traversal().withRemote(DriverRemoteConnection('wss://neptunedbcluster.neptune.amazonaws.com:8182/gremlin','g'))
g.V('p1').as_('this').out('ContributedTo').in_('ContributedTo').where(P.neq('this')).groupCount()
推荐阅读
- python - Python 的 SciPy interpolate.rbf 函数的 Objective C 或 Swift 实现
- vba - VBA/VB6 中的古代日期(2 位数年份)
- java - Sql 多对多查询询问
- typescript - 如何在 typescript 的 Visual Studio 代码中通过完整导入获取编译器错误消息?
- dictionary - 如何在 jsf xhtml 中创建 hashmap
- android - 模拟返回 void 返回类型的存根
- python-3.x - 如何将文本写入pdf文件
- c - 拆分字符串中的空格并将它们存储在没有库的 C 表中
- javascript - 如何在两个相同的模型中选择独特的元素?
- css - 如何在滚动容器中创建渐变叠加?