@Sirius3
Ich habe das Programm eigentlich einmal laufen lassen und dann die Fehlermeldung rauskopiert. Ich habe es jetzt einfach nochmal in einer neuen Konsole gemacht. Ich glaube aber das mit den Teilen liegt daran dass der Code nicht ganz oben steht. Er ist mitten im Skript. Habe jetzt einfach nochmal den Code in die erste zeile Verschoben.
Code: Alles auswählen
import numpy as np
vT = np.full((2,3), np.nan)
vT[1, 0] = 1.1
vT[0, 1] = 2.8
with open ("Hey.txt", 'a') as doc:
np.savetxt(doc, vT, delimiter = '\t', newline = '\n')
Mit folgender Fehlermeldung:
Code: Alles auswählen
Traceback (most recent call last):
File "C:\Users\canan\Desktop\WinPython-64bit-3.5.3.1Qt5\python-3.5.3.amd64\lib\site-packages\numpy\lib\npyio.py", line 1158, in savetxt
fh.write(asbytes(format % tuple(row) + newline))
TypeError: write() argument must be str, not bytes
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\canan\Desktop\untitled0.py", line 9, in <module>
np.savetxt(doc, vT, delimiter = '\t', newline = '\n')
File "C:\Users\canan\Desktop\WinPython-64bit-3.5.3.1Qt5\python-3.5.3.amd64\lib\site-packages\numpy\lib\npyio.py", line 1162, in savetxt
% (str(X.dtype), format))
TypeError: Mismatch between array dtype ('float64') and format specifier ('%.18e %.18e %.18e')
Und hier das Andere:
Code: Alles auswählen
import numpy as np
vT = np.full((2,3), np.nan)
vT[1, 0] = 1
vT[0, 1] = 2
with open("Hey.txt", 'a') as doc:
np.savetxt(doc, vT, delimiter='\t', fmt='%1.4f')
with open('Hey.txt', 'rb') as data:
print(data.read())
mit dem Traceback:
Code: Alles auswählen
Traceback (most recent call last):
File "C:\Users\canan\Desktop\WinPython-64bit-3.5.3.1Qt5\python-3.5.3.amd64\lib\site-packages\numpy\lib\npyio.py", line 1158, in savetxt
fh.write(asbytes(format % tuple(row) + newline))
TypeError: write() argument must be str, not bytes
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\canan\Desktop\untitled0.py", line 8, in <module>
np.savetxt(doc, vT, delimiter='\t', fmt='%1.4f')
File "C:\Users\canan\Desktop\WinPython-64bit-3.5.3.1Qt5\python-3.5.3.amd64\lib\site-packages\numpy\lib\npyio.py", line 1162, in savetxt
% (str(X.dtype), format))
TypeError: Mismatch between array dtype ('float64') and format specifier ('%1.4f %1.4f %1.4f')
@__blackjack__: Es muss der Editor von Windows genommen werden. Wenn das ganze Programm fertig ist (ist sehr viel größer) muss diese Textdatei von verschiedenen Leuten weiterverarbeitet werden. Und leider ist auf den meisten Computern (meines Wissens nach) als einfacher Texteditor halt eben der windows editor vorinstalliert. Und selbst wenn nicht, wissen es die meisten nicht. Ich habe also keine Wahl. Es muss dort drinnen richtig angezeigt werden...
Wenn ich das Programm aus der Konsole starte, kommt wieder die Fehlermeldung:
Code: Alles auswählen
Traceback (most recent call last):
File "C:\Users\canan\Desktop\WinPython-64bit-3.5.3.1Qt5\python-3.5.3.amd64\lib\site-packages\numpy\lib\npyio.py", line 1158, in savetxt
fh.write(asbytes(format % tuple(row) + newline))
TypeError: write() argument must be str, not bytes
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "untitled0.py", line 8, in <module>
np.savetxt(doc, vT, delimiter='\t', fmt='%1.4f')
File "C:\Users\canan\Desktop\WinPython-64bit-3.5.3.1Qt5\python-3.5.3.amd64\lib\site-packages\numpy\lib\npyio.py", line 1162, in savetxt
% (str(X.dtype), format))
TypeError: Mismatch between array dtype ('float64') and format specifier ('%1.4f %1.4f %1.4f')