编辑 :无论出于什么原因,我似乎都无法单独回答这个问题,因此这是一个更清洁的版本,它不需要使用
csv模块。记录下来,@
askewchan的答案还是更好!
a = numpy.array([(1, 2.0, 'buckle_my_shoe'), (3,4.0,'lock_the_door')],dtype=('i4,f8,a14'))with open('test.txt','w') as f: f.write(' '.join([str(item) for sublist in a for item in sublist]))print open('test.txt','r').read()输出:
1 2.0 buckle_my_shoe 3 4.0 lock_the_door



