擅长:python、mysql、java
<p>更具python风格的方法是,要么作为列表:</p>
<pre><code>vals = []
for search_result in search_results:
vals.append(Levenshtein.jaro_winkler(exhibitor_name,urlparse(search_result).netloc.encode('utf-8')))
# Access via vals[0], vals[1], etc.
</code></pre>
<p>或者作为字典:</p>
<pre><code>vals = {}
for search_result in search_results:
vals[search_result] = Levenshtein.jaro_winkler(exhibitor_name,urlparse(search_result).netloc.encode('utf-8'))
# Access via vals[search_result1], vals[search_result2], etc.
</code></pre>
<p>如果你必须对它不好,你可以:</p>
<pre><code>for i in xrange(10):
search_result = locals()['search_result' + str(i)]
locals()['v' + str(i)] = Levenshtein.jaro_winkler(exhibitor_name,urlparse(search_result).netloc.encode('utf-8'))
# Accessed via v0, v1, v2, etc.
</code></pre>
<p>但我不建议这样做,因为这是非肾盂和更迟钝比上述解决方案。你知道吗</p>