擅长:python、mysql、java
<p>可以使用<a href="https://docs.python.org/3/library/ast.html#ast.literal_eval" rel="noreferrer">^{<cd1>}</a>安全地对字符串求值:</p>
<blockquote>
<p>Safely evaluate an expression node or a string containing a Python
literal or container display. The string or node provided may only
consist of the following Python literal structures: strings, bytes,
numbers, tuples, lists, dicts, sets, booleans, and None.</p>
</blockquote>
<pre><code>In [1]: from ast import literal_eval
In [2]: literal_eval("[1,2,3,4,5]")
Out[2]: [1, 2, 3, 4, 5]
</code></pre>