回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我目前有一段代码,用于解析imdbAPI http返回:</p>
<pre><code>text = 'unicode: {"Title":"The Fountain","Year":"2006","Rated":"R","Released":"22 Nov 2006","Genre":"Drama, Romance, Sci-Fi","Director":"Darren Aronofsky","Writer":"Darren Aronofsky, Darren Aronofsky","Actors":"Hugh Jackman, Rachel Weisz, Sean Patrick Thomas, Ellen Burstyn","Plot":"Spanning over one thousand years, and three parallel stories, The Fountain is a story of love, death, spirituality, and the fragility of our existence in this world.","Poster":"http://ia.media-imdb.com/images/M/MV5BMTU5OTczMTcxMV5BMl5BanBnXkFtZTcwNDg3MTEzMw@@._V1_SX320.jpg","Runtime":"1 hr 36 mins","Rating":"7.4","Votes":"100139","ID":"tt0414993","Response":"True"}'
def stripData(tag="Title"):
tag_start = text.find(tag)
data_start = tag_start + len(tag)+3
data_end = text.find('"',data_start)
data = text[data_start:data_end]
return tag, data
</code></pre>
<p>我在想:有没有更好的方法来做我所缺少的?在</p>