Ich habe im Workspace von Eclipe eine test.txt Datei mit dem Inhalt:
Mustermann Max
Musterfrau Anita
Diese Datei habe ich direkt in Eclipse erstellt.
Die Datei möchte ich nun einlesen:
Code: Alles auswählen
#Datei einlesen
with open('test.txt', 'r') as datei:
for line in datei:
#(nachname,vorname) = line.split(' ')
print(line)
pydev debugger: starting (pid: 6900)
Traceback (most recent call last):
File "I:\Frieder\tools\eclipse-java-mars-1-win32-x86_64\eclipse\plugins\org.python.pydev_4.4.0.201510052309\pysrc\pydevd.py", line 2364, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "I:\Frieder\tools\eclipse-java-mars-1-win32-x86_64\eclipse\plugins\org.python.pydev_4.4.0.201510052309\pysrc\pydevd.py", line 1784, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "I:\Frieder\tools\eclipse-java-mars-1-win32-x86_64\eclipse\plugins\org.python.pydev_4.4.0.201510052309\pysrc\_pydev_imps\_pydev_execfile.py", line 13, in execfile
contents = stream.read()
File "C:\Python34\lib\codecs.py", line 319, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf6 in position 130: invalid start byte
Folgendes hat auch nicht gebracht:
Code: Alles auswählen
with open(oldfile, 'r', encoding='utf-8') as infile:
http://stackoverflow.com/questions/9282 ... -statement
Danke schon jetzt für eure Hilfe