Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Change string into Dict
#3
Just to demonstrate what you can do using Python json module.

sampleObj = {
  "car1": { "name":"Ford", "price":35000},
  "car2": { "name":"BMW", "price":65000}
 }

str = json.dumps(sampleObj, indent=4)
print(str)
use the json.dumps()
Reply


Messages In This Thread
Change string into Dict - by Robin_at_Cantelli - May-02-2018, 01:49 PM
RE: Change string into Dict - by gruntfutuk - May-02-2018, 02:01 PM
RE: Change string into Dict - by vishalhule - Mar-05-2020, 10:37 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  change string in MS word Mr_Blue 8 3,218 Sep-19-2021, 02:13 PM
Last Post: snippsat
  Question about change hex string to integer sting in the list (python 2.7) lzfneu 1 2,490 May-24-2021, 08:48 AM
Last Post: bowlofred
Question dict value, how to change type from int to list? swissjoker 3 2,694 Dec-09-2020, 09:50 AM
Last Post: perfringo
  String index out of bounds ( Python : Dict ) kommu 2 2,351 Jun-25-2020, 08:52 PM
Last Post: menator01
  How can I change a string. Mike Ru 3 2,379 Jun-03-2020, 10:55 AM
Last Post: buran
  TypeError: __repr__ returned non-string (type dict) shockwave 0 3,152 May-17-2020, 05:56 PM
Last Post: shockwave
  Sort a dict in dict cherry_cherry 4 62,783 Apr-08-2020, 12:25 PM
Last Post: perfringo
  dict elements are sometimes treated as List and sometimes as String phython_mdr 4 2,645 Apr-01-2020, 12:47 PM
Last Post: phython_mdr
  TypeError: size; expecting a recognized type filling string dict a11_m11 0 2,488 Feb-10-2020, 08:26 AM
Last Post: a11_m11
  [split] capitalize dict keys for display in string newbieAuggie2019 3 2,939 Oct-10-2019, 10:50 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020