LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-22-2016, 09:51 AM   #1
PoleStar
Member
 
Registered: Jul 2010
Posts: 231

Rep: Reputation: 2
pythong json quesion.


Hi,

How can I print or get
Quote:
u'temp': 272.76,
u'temp_max': 274.15
u'temp_min': 271.15
from the this output/structure.

Code:
>>> pprint(r.json())
Code:
{u'base': u'stations',
 u'clouds': {u'all': 90},
 u'cod': 200,
 u'coord': {u'lat': 43.7, u'lon': -79.42},
 u'dt': 1479823800,
 u'id': 6167865,
 u'main': {u'humidity': 90,
           u'pressure': 1024,
           u'temp': 272.76,
           u'temp_max': 274.15,
           u'temp_min': 271.15},
 u'name': u'Toronto',
 u'sys': {u'country': u'CA',
          u'id': 3721,
          u'message': 0.1575,
          u'sunrise': 1479817329,
          u'sunset': 1479851146,
          u'type': 1},
 u'visibility': 14484,
 u'weather': [{u'description': u'light snow',
               u'icon': u'13d',
               u'id': 600,
               u'main': u'Snow'}],
 u'wind': {u'deg': 290, u'speed': 4.1}}
and what is with 'u' every where in this structure ?

Thank you.
 
Old 11-22-2016, 12:05 PM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 20,241

Rep: Reputation: 6836Reputation: 6836Reputation: 6836Reputation: 6836Reputation: 6836Reputation: 6836Reputation: 6836Reputation: 6836Reputation: 6836Reputation: 6836Reputation: 6836
you need to check how to use python dictionaries.
check: r.json()["main"]["temp"]
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiline sed quesion jax8 Linux - Software 2 03-31-2009 03:42 PM
sftp quesion mokku Linux - Newbie 1 04-18-2008 02:42 PM
/etc/sysconfig/network quesion mokku Linux - Newbie 5 03-13-2008 09:35 AM
New with Linux, and have a quesion strello Linux - Software 1 10-25-2006 01:49 PM
redhat 9 quesion the anti-riced Linux - Newbie 2 06-08-2003 05:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration