0

我有一个dict对象,我试图在其中解析并仅捕获字符串的一部分。

我正在使用 McAfee EPO Python API,可以获取查询结果,但我认为这与这个问题无关。

这是对象中的字符串(多行类似内容)。我'WORKSTATION001'要从这个字符串中提取文本。

{u'EPOLeafNode.NodeName': u'WORKSTATION001'}

这是我正在使用的代码:

for system in epoSystems:
    computerName = system.rstrip().split('u')
    print computerName

这导致:

    computerName = system.rstrip().split('u')
AttributeError: 'dict' object has no attribute 'rstrip'

关于如何抓住那个字符串的任何想法?

4

1 回答 1

0

感谢您的快速回复。通过 system[u'EPOLeafNode.NodeName'] 引用就可以了。

更新(工作)代码:

for system in epoSystems:
    computerName = system[u'EPOLeafNode.NodeName']
    print computerName
于 2018-06-06T20:40:00.687 回答