Python Forum

Full Version: New to Python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I'm new to Python and working on same basic data manipulation scripts to strip specific objects and values from an API call.

The lenght of the list is 326 rows, im specially working on row 2 for now as you can see below.

print "datatype for a", type(a)
p =  a[2]
print p
print type(p)

import collections
testing = collections.OrderedDict(p)
for y in testing:
        print(y)
When I run the Python script i get the following results below.

How come for example the domain is returned but the object value (assuming it is an object) is not, i want to be able to strip out the domain and value, which in this case should 'domian' and '*.mywebsite.com'.

Struggling to figure this out. Anyone any ideas? Doh

Thanks!

Output:
datatype for a <type 'list'> {u'domain': u'*.mywebsite.com', u'short_answers': [u'1.1.1.1'], u'ttl': 3600, u'tier': 1, u'type': u'A', u'id': u'0000000000000000005'} <type 'dict'> domain short_answers ttl tier type id
Do you mean this ?
for key, value in testing.items():
    print(key, value)
(Apr-11-2018, 11:39 AM)Gribouillis Wrote: [ -> ]Do you mean this ?
for key, value in testing.items():
    print(key, value)

Perfect that worked a treat! That easy Smile