我有一个像这样的字符串:
"probability": {"go": 0.63549300785454799, "stand": 0.15739544829291019, "stop": 0.36450699214545207}, "label": "go"
在此字符串中,我只想提取' },“ '之后的部分,即
"label": "go"
该字符串是在循环中生成的,因此必须在循环本身内执行此操作。同样,字符串不同部分的长度也不是恒定的。如何提取字符串的所需部分?
thestring = '"probability": {"go": 0.63549300785454799, "stand": 0.15739544829291019, "stop": 0.36450699214545207}, "label": "go"'
print thestring.split('}, ')[1]
输出:
"label": "go"
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句