Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8340417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:10:33+00:00 2026-06-09T05:10:33+00:00

I have a json document (as_stats.json) that looks something like this: {failed:5, received: {192.168.5.2:

  • 0

I have a json document (as_stats.json) that looks something like this:

{"failed":5, "received": {"192.168.5.2": 40, "192.168.5.45": 84, "127.0.0.1": 145}}

My python code looks like this:

import json,urllib
data = open('as_stats.json').read()
d = json.loads(data)

for x in d['received']:
    if (x != '127.0.0.1'):
        print x

The values returned are the IP addresses, which are variables i.e. the could change any time to any other address. What I am interested in is the number of files received from each IP address as well. When I try rewriting my code as

for x,y in d['received']:
        if (x <> '127.0.0.1'):
            print x,y

I get a message saying “too many values to unpack”.

How do I go about getting the values that I want from the key-value pairs?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T05:10:35+00:00Added an answer on June 9, 2026 at 5:10 am

    Use:

    for x,y in d['received'].iteritems():
    

    Normal iteration over a dict will give you only the keys. Use itervalues to get the values, or iteritems to get both keys and values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have JSON text that looks like this: { ok: true, totalPages: 256, arReports:
I have JSON like this: { something: http://something.com } and HTML like this: <a
i have json data like this {GetStudentDetails: {TotalCount:5, RootResults:[ {city:West Chester,country:USA,state:PA ,student_id:100}, {city:Philly,country:USA,state:PA,student_id:101}, {city:Buffalo,country:USA,state:NY,student_id:102},
I'm implementing a service where each user must have his own json/document database. Beyond
I have updated my jSon object using the code <script type=text/javascript > jQuery(document).ready(function($){ var
I have the following simple jquery snippet $(document).ready(function () { $.ajax({ url:myjson.json, dataType: 'json',
I have JSON string that has nested objects with dynamic names that vary each
I have JSON that keep changing , I need in android to keep updating
I have a JSON format result sent back to the client that hold the
I have a geo collection that contains items like: [state name] [city], [state] [country]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.