<pre><code>result = ['袁惟仁', None, 'Life']
# Replace None with empty string
response = ['' if s is None else s for s in result]
# Handle non-ascii characters
return [s.encode('utf-8') if isinstance(s, unicode) else str(s) for s in response]
</code></pre>
<p>在这段代码中,我用“”替换list的None值,然后处理Unicode字符。这很管用,但我想知道是否有更好的方法。现在如果我不处理empty,我会得到一个错误,说不能将<strong>None</strong>转换为str</p>