<p>下面是简单的代码:</p>
<pre><code>s = ['-1', '2', '+']
print([x.isnumeric() for x in s])
print([x.isdigit() for x in s])
</code></pre>
<p>输出为</p>
<pre><code>[False, True, False]
[False, True, False]
</code></pre>
<p>我的愿望是:</p>
<pre><code>[True, True, False]
</code></pre>
<p>还可以使用正则表达式模式匹配负数、正数和十进制数:</p>
<pre><code>>>> import re
>>> s = ['-1', '2', '+']
>>> [re.match('^(-|\+)?\d+(.\d+)?', n) is not None for n in s]
[True, True, False]
>>>
</code></pre>