Python Forum
extract a dictionary from a string
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
extract a dictionary from a string
#1
Hello everyone
Please help me solve my little problem.
Created an object in canvas tkinter (canvas.create_image(bot['coord'], image = bot['image'], tags = ('bot', bot ['name'], tag1))) and passed the dictionary as a tag (tag1) - {'name': 'bot_28', 'coord': (610, 160), 'health': 0.99, 'live': 0, 'age': 0, 'speed': 0.41, 'orient': 7, 'cargo': [], 'atak': 0.521, 'radar': 25, 'step': 0, 'near': [], 'image': <PIL.ImageTk.PhotoImage object at 0x000001D3269081D0>}. The dictionary in the tag gets the string type.
Now I need to extract it, but I can't convert it back from a string to a dictionary - an error appears ('str' object has no attribute 'keys' - I wanted to see all the dictionary keys). I don't know how to fix it?
Reply


Messages In This Thread
extract a dictionary from a string - by berc - Jul-28-2020, 05:36 PM
RE: extract a dictionary from a string - by berc - Jul-29-2020, 02:04 AM
RE: extract a dictionary from a string - by berc - Jul-30-2020, 06:58 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Converting '1a2b3c' string to Dictionary PythonNoobLvl1 6 471 May-13-2022, 03:44 PM
Last Post: deanhystad
  Extract a string between 2 words from a text file OscarBoots 2 857 Nov-02-2021, 08:50 AM
Last Post: ibreeden
  How to extract specific key value pair from string? aditi06 0 1,466 Apr-15-2021, 06:26 PM
Last Post: aditi06
  Beautify dictionary without converting to string. sharoon 6 1,775 Apr-11-2021, 08:32 AM
Last Post: buran
Question How to extract multiple text from a string? chatguy 2 1,263 Feb-28-2021, 07:39 AM
Last Post: bowlofred
  Extract continuous numeric characters from a string in Python Robotguy 2 1,436 Jan-16-2021, 12:44 AM
Last Post: snippsat
  Extract data from large string pzig98 1 1,350 Jul-20-2020, 12:39 AM
Last Post: Larz60+
  simple f-string expressions to access a dictionary Skaperen 0 965 Jul-15-2020, 05:04 AM
Last Post: Skaperen
  xml.etree.ElementTree extract string values matthias100 2 2,221 Jul-12-2020, 06:02 PM
Last Post: snippsat
  problem coverting string data file to dictionary AKNL 22 3,698 Mar-10-2020, 01:27 PM
Last Post: AKNL

Forum Jump:

User Panel Messages

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