How to display elements in an element?

Asked 2 years ago, Updated 2 years ago, 44 views

dict={'MENTION':'{'MENTION':'{'MENTION':'{'MENTION':'0','E':'10','M':'xxxx'}}

What should I do to show the xxxxx part of something like this?

python

2022-09-30 21:22

2 Answers

'{"MENTIONEES":[{"S":"0", "E":"10", "M":"xxxx"}}'

The string is valid as both Python dictionary literal and JSON.
You need to understand where this string comes from and what format it follows and treat it in the correct way.
Since the existing answer from BLUEPIXY is to treat Python as literal, I will show you how to parse as JSON.

(Python has a class called dict as the global variable dict, so overwriting it is confusing.d is used as the variable name below.)


2022-09-30 21:22

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.