Page 57 - Python Cơ Bản
P. 57

import json




           mystring = '{"a":1,"b":2,"c":3,"d":4,"e":5}'

           data = json.loads(mystring)

           print data

           (HiӅn thӍ: {u'a': 1, u'c': 3, u'b': 2, u'e': 5, u'd

           ': 4})





               )RGSHMRK .732 (EXE






          2ЎY RLš FϰR чɪ Gɹ QШX FMЎR Zɧ QYРR IRGSHI XLɧRL .732


          WXVMRK XLɳ Gɹ XLВ HɽRK XLIS GɨGL WEY





           import json



           mydata = {

               'name': 'John',

               'age': 10

           }

           jsonstring = json.dumps(mydata)

           print jsonstring

           (hiӅn thӍ: {"age": 10, "name": "John"})
   52   53   54   55   56   57   58   59   60   61   62