<p>你的术语有点混乱。你知道吗</p>
<p><code>Python</code>没有标量。它的基本对象是数字、字符串和列表。列表可以是字符串列表、数字列表或混合列表。你知道吗</p>
<p><code>numpy</code>在<code>Python</code>的基础上添加多维数组的概念。通常这些数组的元素是数字。<code>numpy</code>数组可以包含单个数字(具有0维)。<code>Numpy</code>文档通过将“普通”Python编号称为“标量”来区分这样的数组和“普通”Python编号。你知道吗</p>
<p>但你真正想问的是一种显示numpy数组的方法。你知道吗</p>
<pre><code>In [156]: a=np.arange(10) # a numpy array of integers
In [157]: str(a)
Out[157]: '[0 1 2 3 4 5 6 7 8 9]' # a string representation of that array
In [158]: a.tolist()
Out[158]: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] # a list of numbers
In [159]: str(a.tolist())
Out[159]: '[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]' # a string representation of that list
In [160]: [str(i) for i in a]
Out[160]: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] # a list of strings
In [161]: ', '.join(_)
Out[161]: '0, 1, 2, 3, 4, 5, 6, 7, 8, 9' # join the strings into one
In [169]: a.astype(str)
Out[169]: array(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], dtype='|S24')
# an array of strings
</code></pre>
<p>不要混淆数组(或任何Python对象)的显示方式(转换为字符串)和数组的性质。在处理数组或列表等复合对象时,表示对象整体的方式和表示对象元素的方式是有区别的。你知道吗</p>
<hr/>
<p>在你的例子中</p>
<pre><code>>>> s=[]
>>> [s.append(str(i)) for i in range(11)]
</code></pre>
<p>你不需要附加。你知道吗</p>
<pre><code>s = [str(i) for i in range(11)]
</code></pre>
<p>自动生成列表。事实上,列表理解是以下内容的一个紧凑而快速的版本:</p>
<pre><code>s = []
for i in range(11):
s.append(str(i))
</code></pre>
<p><code>map</code>也可以,但是Python开发人员鼓励我们使用理解。你知道吗</p>