AttributeError when splitting a string

1k Views Asked by At

I have a dict object in which I'm trying to parse out and capture only a part of the string.

I'm using McAfee EPO Python API's and can grab results of a query, but I don't think that is relevant to this question.

Here is the strings in the objects (multiple lines of similar content). What I'm after is extracting the 'WORKSTATION001' text from this string.

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

Here's the code I'm using:

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

This results in:

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

Any ideas on how to grab just that string?

1

There are 1 best solutions below

0
On

Thanks for the quick responses. Referencing via system[u'EPOLeafNode.NodeName'] did the trick.

Updated (working) code:

for system in epoSystems:
    computerName = system[u'EPOLeafNode.NodeName']
    print computerName