简体   繁体   中英

how to take json format in python

I have a json

format = [
  {
     "Deskripsi": "Anda baik dalam Bersikap tegas dan menolak hal yang tidak disukai"
  }
]

I wrote this script which prints all of the json text:

io = StringIO()
json.dump(format,io)
return io.getvalue() 

How can I take the "Anda baik dalam Bersikap tegas dan menolak hal yang tidak disukai" from the json format?

First of all, format is not JSON . Is a python list containing a dictionary.

You could get what you want by doing:

format[0]["Deskripsi"]

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