[1,2,4,7,5,2]
カンマを削除したいリストがあるのですが、[1 2 4 7 5 2]
どうすればよいでしょうか?
np.random.randint(0,4,12)[0 3 4 1 3 4 2 1 2 4 3 4]
のように出力され、それが私が望む種類のものです:)
あなたはこれを行うことができます:
out = '[' + ' '.join(str(item) for item in numbers)+ ']'
print out
In [7]: data = [1,2,4,7,5,2]
In [11]: '[{}]'.format(' '.join(map(str, data)))
Out[11]: '[1 2 4 7 5 2]'
また、
In [14]: str(data).replace(',','')
Out[14]: '[1 2 4 7 5 2]'
numpy ndarray が必要な場合は、次を使用します。
np.array([1, 2, 4, 7, 5, 2])