擅长:python、mysql、java
<p>示例文本无效<a href="http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf" rel="nofollow">JSON text</a>。JSON字符串必须以<a href="http://unicode.org/cldr/utility/character.jsp?a=0022" rel="nofollow">^{<cd1>} quotation mark</a>开头,而不是<code>'</code>;但它似乎是一个可以用<a href="http://docs.python.org/2/library/ast.html#ast.literal_eval" rel="nofollow">^{<cd3>} function</a>解析的有效Python文本:</p>
<pre><code>import ast
data = ast.literal_eval(input_string)
for item in data["result"]:
print("{total}, {_id}".format(**item))
</code></pre>
<h3><a href="http://ideone.com/RQtqoq" rel="nofollow">Output</a></h3>
<pre><code>142250.0, BC
210.89, USD
1065600.0, TK
</code></pre>
<p>一个更好的方法可能是修复查询过程以获得有效的JSON并使用<code>json</code>模块来解析它。</p>