Write a NumPy program to save as text a matrix which has in each row 2 float and 1 string at the end

  • برمجة بايثون

Write a NumPy program to save as text a matrix which has in each row 2 float and 1 string at the end.

الأجوبة

import numpy as np
matrix = [[1, 0, 'aaa'], [0, 1, 'bbb'], [0, 1, 'ccc']]
np.savetxt('test', matrix, delimiter='  ', header='string', comments='', fmt='%s')

Sample Output:
string
1  0  aaa
0  1  bbb
0  1  ccc
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...