当前位置: 首页>>代码示例>>Python>>正文


Python TreeDict.getClosestKey方法代码示例

本文整理汇总了Python中treedict.TreeDict.getClosestKey方法的典型用法代码示例。如果您正苦于以下问题:Python TreeDict.getClosestKey方法的具体用法?Python TreeDict.getClosestKey怎么用?Python TreeDict.getClosestKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在treedict.TreeDict的用法示例。


在下文中一共展示了TreeDict.getClosestKey方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testMatch_06

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import getClosestKey [as 别名]
 def testMatch_06(self):
     p = TreeDict()
     p.a.b = 1
     p.a.a.b = 1
     p.a.a.a.c = 1
     self.assert_(p.getClosestKey('a.ab') == 'a.a.b')
     self.assert_(p.getClosestKey('a.ab',1) == ['a.a.b'])
开发者ID:real666maverick,项目名称:treedict,代码行数:9,代码来源:test_matching.py

示例2: testMatch_16_first

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import getClosestKey [as 别名]
 def testMatch_16_first(self):
     p = TreeDict()
     p.asdfdjdjd.eiudkdkdk = 1
     p.basdfdjdjd.eiudkddk = 1
     p.a.b = None
     
     self.assert_(p.getClosestKey('asdfdjdjd', 2) == 
                  ['asdfdjdjd.eiudkdkdk', 'basdfdjdjd.eiudkddk'], p.getClosestKey('asdfdjdjd', 2))
开发者ID:real666maverick,项目名称:treedict,代码行数:10,代码来源:test_matching.py

示例3: testMatch_08

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import getClosestKey [as 别名]
    def testMatch_08(self):
        p = TreeDict()
        p.ab = 1
        p.a.b = 1
        p.a.ab = 1
        p.a.a.b = 1
        p.a.a.bc = 1
        p.a.a.a.c = 1

        self.assert_(p.getClosestKey('', 4) == ['ab', 'a.b', 'a.ab', 'a.a.b'])
开发者ID:real666maverick,项目名称:treedict,代码行数:12,代码来源:test_matching.py

示例4: testMatch_03

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import getClosestKey [as 别名]
 def testMatch_03(self):
     p = TreeDict()
     p.set(a=1, b=1, c=1, d=1,e=1,f=1)
     self.assert_(p.getClosestKey('cc') == 'c')
     self.assert_(p.getClosestKey('cc', 1) == ['c'])
开发者ID:real666maverick,项目名称:treedict,代码行数:7,代码来源:test_matching.py

示例5: testMatch_02

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import getClosestKey [as 别名]
 def testMatch_02(self):
     p = TreeDict()
     p.aa = 1
     p.bb = 1
     self.assert_(p.getClosestKey('a') == 'aa')
     self.assert_(p.getClosestKey('a',1) == ['aa'])
开发者ID:real666maverick,项目名称:treedict,代码行数:8,代码来源:test_matching.py

示例6: testMatch_13_empty

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import getClosestKey [as 别名]
 def testMatch_13_empty(self):
     p = TreeDict()
     self.assert_(p.getClosestKey('') is None)
     self.assert_(p.getClosestKey('', 1) == [])
     self.assert_(p.getClosestKey('', 10000) == [])
开发者ID:real666maverick,项目名称:treedict,代码行数:7,代码来源:test_matching.py

示例7: testMatch_15_last

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import getClosestKey [as 别名]
 def testMatch_15_last(self):
     p = TreeDict()
     p.asdfdjdjd.eiudkdkdk = 1
     p.basdfdjdjd.eiudkddk = 1
     
     self.assert_(p.getClosestKey('asdfjd.eiudkdkdk') == 'asdfdjdjd.eiudkdkdk')
开发者ID:real666maverick,项目名称:treedict,代码行数:8,代码来源:test_matching.py

示例8: testMatch_12_empty

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import getClosestKey [as 别名]
 def testMatch_12_empty(self):
     p = TreeDict()
     self.assert_(p.getClosestKey('123221321321') is None)
     self.assert_(p.getClosestKey('123221321321', 1) == [])
     self.assert_(p.getClosestKey('123221321321', 10000) == [])
开发者ID:real666maverick,项目名称:treedict,代码行数:7,代码来源:test_matching.py

示例9: testMatch_11

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import getClosestKey [as 别名]
 def testMatch_11(self):
     p = TreeDict()
     p.a.b = 1
     p.a.a.b = 1
     p.a.a.a.c = 1
     self.assert_(p.getClosestKey('', 200000) == ['a.b', 'a.a.b', 'a.a.a.c'])
开发者ID:real666maverick,项目名称:treedict,代码行数:8,代码来源:test_matching.py

示例10: testMatch_10

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import getClosestKey [as 别名]
 def testMatch_10(self):
     p = TreeDict()
     p.set(gambol = 2, bumble = 3, borkborkbork=None)
     self.assert_(p.getClosestKey('gumbo', 2) == ['gambol', 'bumble'])
开发者ID:real666maverick,项目名称:treedict,代码行数:6,代码来源:test_matching.py

示例11: testMatch_09

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import getClosestKey [as 别名]
 def testMatch_09(self):
     p = TreeDict()
     p.set(gambol = 2, bumble = 3)
     self.assert_(p.getClosestKey('gumbo') == 'gambol')
     self.assert_(p.getClosestKey('gumbo', 1) == ['gambol'])
开发者ID:real666maverick,项目名称:treedict,代码行数:7,代码来源:test_matching.py

示例12: TreeDict

# 需要导入模块: from treedict import TreeDict [as 别名]
# 或者: from treedict.TreeDict import getClosestKey [as 别名]
t = TreeDict(x = 1)
t.get("x")
t.get("y")
t.get("y", [])

########################################
# getClosestKey

t = TreeDict()
t.alpha.x1 = 1
t.alpha.y1 = 1
t.alpha.zzz = 1
t.beta.x = 1
t.gamma.beta = 1
"alpah.x" in t
t.getClosestKey("alpah.x")
t.getClosestKey("alpah.x", 1)
t.getClosestKey("alpah.x", 3)

########################################
# hash

from treedict import TreeDict
t = TreeDict()
t.set('br.x', 1, 'br.c.y', 2, x = 1, y = 2)
t.hash()
t.hash('br')
t.br.hash()
t.br.hash(add_name = True)
t.hash('x')
t.hash(keys = ['x', 'y'])
开发者ID:aurora1625,项目名称:treedict,代码行数:33,代码来源:docstringscraps.py


注:本文中的treedict.TreeDict.getClosestKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。