簡體   English   中英

py2neo NodeMatcher 謂詞

[英]py2neo NodeMatcher Predicates

嘗試在NodeMatcher()使用謂詞......我在這里做錯了嗎?

In [24]: nodes = NodeMatcher(neodb)

In [25]: nodes.match("Interface", ipv4=STARTS_WITH("192.168.240.170")).first()
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-25-22cdc9c394bd> in <module>
----> 1 nodes.match("Interface", ipv4=STARTS_WITH("192.168.240.170")).first()

NameError: name 'STARTS_WITH' is not defined

語法不正確。 請參考此文檔: https : //py2neo.org/v4/matching.html

您應該為該屬性添加 __startswith 后綴。 例如:

nodes.match("Interface", ipv4__startswith="192.168.240.170").first()

解決方案是我需要導入謂詞類:

In [13]: from py2neo.matching import STARTS_WITH
In [14]: nodes.match("Interface", ipv4=STARTS_WITH("192.168")).first()
Out[14]: Node('Interface', admin=True, description='inside', hostUUID='asa-core', ipv4='192.168.199.11/27', name='GigabitEthernet0/0', operational=True)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM