How to convert dictionary to JSON in Python

1 Answer

0 votes
import json   
       
dict = {   
  "id": "1",   
  "name": "Tom",   
  "password": "123456"
}   
       
js = json.dumps(dict, indent = 4)   

print(js)  

    
           
      
'''
run:
  
{
    "id": "1",
    "name": "Tom",
    "password": "123456"
}
            
'''

 



answered May 13, 2020 by avibootz

Related questions

1 answer 324 views
1 answer 335 views
1 answer 248 views
1 answer 192 views
192 views asked Jul 24, 2022 by avibootz
1 answer 220 views
1 answer 199 views
199 views asked Sep 20, 2021 by avibootz
...