简体   繁体   中英

PYTHON: How to show print username and password?

import json

x = ''' {
   "result":{
      "firstList":[
         {
            "username":"a@gmail.com",
            "password":"123"
         }
      ]
   },
   "size":1,
   "took":436
} ''' # The Json

seloco = json.loads(x)
print(seloco) # Print Json

How can I print username and password?

Like that:

>>> print(seloco['result']['firstList'][0]['username'])
a@gmail.com
>>> print(seloco['result']['firstList'][0]['password'])
123
import json x = ''' { "result":{ "firstList":[ { "username":"a@gmail.com", "password":"123" } ] }, "size":1, "took":436 } ''' # The Json seloco = json.loads(x) print(seloco) # Print Json user = seloco["result"]["firstList"][0] username = user["username"] password = user["password"] print(username) print(password)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM