Problem with Germans letter in file, Python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Problem with Germans letter in file, Python

Hi ! I have a huge document with all German words, where each word begins with a new line. But the problem is, when I want pull up the word from a file, it doesn’t show Germans letter: https://code.sololearn.com/cIqBuPeDlJUK/?ref=app Also it occurs / at the beginning of the word, what I don’t need. Can someone explain how can I fix it?

24th Mar 2020, 1:17 PM
Katja
Katja - avatar
19 Answers
+ 5
Oma Falk , HonFu also nach den 5 Stunden habe ich einfach die datei in reinen text umgewandelt und alles funktioniert jetzt🥳 danke euch für die hilfe👍
24th Mar 2020, 10:05 PM
Katja
Katja - avatar
+ 4
hoffe, es ist p3 compatible. habe es mal kurz angetestet
24th Mar 2020, 1:40 PM
Oma Falk
Oma Falk - avatar
+ 3
Katja kannst du das zeug mal in notepad reinhauen und in irgendeine definierte Codierung umwandeln?
24th Mar 2020, 5:01 PM
Oma Falk
Oma Falk - avatar
+ 3
My advice Try to open the data file with a decent text editor, eg. Notepad++ It normally displays the encoding, such as UTF-8 Try to match the python encoding parameter of the open() function, with the file... Python default is utf-8 (unicode) but most likely your file is in a different format.
24th Mar 2020, 5:56 PM
Tibor Santa
Tibor Santa - avatar
+ 2
https://www.python-forum.de/viewtopic.php?t=5095
24th Mar 2020, 1:34 PM
Oma Falk
Oma Falk - avatar
+ 2
Oma Falk, das sieht stark nach Python 2 aus...
24th Mar 2020, 1:39 PM
HonFu
HonFu - avatar
+ 2
Vieles sieht obsolet aus, u-Strings und so.
24th Mar 2020, 1:41 PM
HonFu
HonFu - avatar
+ 2
Katja, so lustig das klingt, aber kannst du einfach mal versuchen, das encoding wegzulassen? Ändert das was?
24th Mar 2020, 1:42 PM
HonFu
HonFu - avatar
+ 2
I don't see any problem. May be the file is encoded wrongly. please checkout the file correctly.
24th Mar 2020, 3:46 PM
Ishmam
Ishmam - avatar
+ 2
HonFu, neee, hab schon versucht, bringt einfach nichts😭
24th Mar 2020, 4:26 PM
Katja
Katja - avatar
+ 2
Ja, wie's auf dem Screen aussieht, muss leider nicht unbedingt was heißen.
24th Mar 2020, 5:29 PM
HonFu
HonFu - avatar
+ 2
HonFu sehe ich doppelt? jeder Post 2x?
24th Mar 2020, 9:30 PM
Oma Falk
Oma Falk - avatar
+ 2
Haha, jo, das ist in der Regel die Lösung. 🤣 Schön, dass es geklappt hat!
24th Mar 2020, 11:41 PM
HonFu
HonFu - avatar
+ 1
Hört sich für mich auch so an, als könnte es an der Datei liegen. Ihr lasst das nicht in 'ner komischen Umgebung wie QPython3 oder so laufen? (Ich krieg da manchmal recht seltsamen Zeichensalat präsentiert.)
24th Mar 2020, 4:28 PM
HonFu
HonFu - avatar
+ 1
HonFu, ja, kann ehrlich gesagt sein. Ich habe die datei erstmal als .dic heruntergeladen und dann als .txt gemacht. Vielleicht liegt das Problem darin, dass ich das mit ios system verändert habe, aber ich weiß dann immernoch nicht, wie kann ich das Problem lösen, weil die Datei sieht erstamal gut aus( also jedes Wort beginnt mit der neuen Zeile und alle deutsche Buchstaben sind richtig geschrieben ).
24th Mar 2020, 4:37 PM
Katja
Katja - avatar
+ 1
or use HxD to inspect your file and check if the „extra characters“ are really there or not. https://en.m.wikipedia.org/wiki/HxD
24th Mar 2020, 5:53 PM
Edward
Edward - avatar
0
Edward ,you are right , it looks terribly now
24th Mar 2020, 7:33 PM
Katja
Katja - avatar
0
you are right guys, it is the problem with the file. It shows you all words that are correct , but in fact it looks different , what python showed me https://code.sololearn.com/cRC8hJ844WaU/?ref=app
24th Mar 2020, 7:48 PM
Katja
Katja - avatar
0
M="german letter".encode("utf-8")
25th Mar 2020, 4:36 PM
ZeroDay
ZeroDay - avatar