作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个从 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 - 如何在 Gremlin-Python 中使用 "neq"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53588570/
我是一名优秀的程序员,十分优秀!