【发布时间】:2012-08-17 00:43:37
【问题描述】:
谁能指出我在这里做错了什么?
import numpy as np
a = np.array([1,2,3,4,5],dtype=int)
b = np.array(['a','b','c','d','e'],dtype='|S1')
np.savetxt('test.txt',zip(a,b),fmt="%i %s")
输出是:
Traceback (most recent call last):
File "loadtxt.py", line 6, in <module>
np.savetxt('test.txt',zip(a,b),fmt="%i %s")
File "/Users/tom/Library/Python/2.6/site-packages/numpy/lib/io.py", line 785, in savetxt
fh.write(format % tuple(row) + '\n')
TypeError: %d format: a number is required, not numpy.string_
【问题讨论】: