Reputation: 1695
I have a string like :
"probability": {"go": 0.63549300785454799, "stand": 0.15739544829291019, "stop": 0.36450699214545207}, "label": "go"
Of this string, i want to extract only the part after '}, "', i.e.
"label": "go"
This string is generated in a loop, hence have to perform this action within the loop itself. Also, the length of the different parts of the string is not constant. How may I extract the desired part of the string?
Upvotes: 0
Views: 76
Reputation: 8376
thestring = '"probability": {"go": 0.63549300785454799, "stand": 0.15739544829291019, "stop": 0.36450699214545207}, "label": "go"'
print thestring.split('}, ')[1]
Output:
"label": "go"
Upvotes: 1