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 322 views
1 answer 333 views
1 answer 246 views
1 answer 190 views
190 views asked Jul 24, 2022 by avibootz
1 answer 216 views
1 answer 196 views
196 views asked Sep 20, 2021 by avibootz
...