Skip to content
Advertisement

how to analysis String contain multiple list in python

I have a string as follows

JavaScript

I use json.load with ast.literal_eval neither works

Is there any function that can quickly and perfectly parse this string?

hope through like

JavaScript

output: C

Advertisement

Answer

The string does not represent a valid Python construct. Therefore, neither eval nor ast.literal_eval will be able to parse it. However, it appears that all you need to do is insert a comma in the appropriate position. You could do it like this:

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement