1. 程式人生 > >python寫入換行

python寫入換行

a
array([[‘a’, ‘b’, ‘c’, ‘d’, ‘message’],
[‘1’, ‘2’, ‘3’, ‘4’, ‘hello’],
[‘5’, ‘6’, ‘7’, ‘8’, ‘world’],
[‘9’, ‘10’, ‘11’, ‘12’, ‘foo’]], dtype=’<U7’)

lists=[str(line)+"\n" for line in a]
f.writelines(lists)
f.close()
f=open(“ex1.csv”,“w+”)
f.writelines(lists)
f.close()