Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New to Python
#1
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
Reply
#2
Do you mean this ?
for key, value in testing.items():
    print(key, value)
Reply
#3
(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
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020