Ich habe ein <class 'numpy.ndarray'>
Objekt, das ich möchte es in einer TXT-Datei speichern. Das Objekt hat Abmessungen (Form) (130, 118, 118)
und Größe 1810120
.Speichern Sie numpy ndarray in eine TXT-Datei
Wenn ich versuche, np.savetxt(f, object, delimiter=' ', fmt='1.10f')
mit f = open('test.txt', 'wb')
zu verwenden, erhalte ich die Fehler
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\G****\Anaconda3\lib\site-packages\numpy\lib\npyio.py", line 1139, in savetxt
raise error
ValueError: fmt has wrong number of % formats: 1.10f
ich verschiedene Kombinationen von 1. f versucht, aber keine gearbeitet hat. Vorschläge irgendjemand?
UPDATE: Nachdem Sie die Vorschläge von den Kommentaren unten, und das Hinzufügen von fmt='%1.10f'
ich diese erhalten:
Traceback (most recent call last):
File "C:\Users\G****\Anaconda3\lib\site-packages\numpy\lib\npyio.py", line 1158, in savetxt
fh.write(asbytes(format % tuple(row) + newline))
TypeError: only length-1 arrays can be converted to Python scalars
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\G****\Anaconda3\lib\site-packages\numpy\lib\npyio.py", line 1162, in savetxt
% (str(X.dtype), format))
TypeError: Mismatch between array dtype ('int8') and format specifier ('%1.10f...... the '%1.10f goes on for quite a while)
versuchen: 'fmt = '% 1.10f'' –