Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis+ 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?
19 Respostas
+ 4
hoffe, es ist p3 compatible.
habe es mal kurz angetestet
+ 3
Katja kannst du das zeug mal in notepad reinhauen und in irgendeine definierte Codierung umwandeln?
+ 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.
+ 2
https://www.python-forum.de/viewtopic.php?t=5095
+ 2
Vieles sieht obsolet aus, u-Strings und so.
+ 2
Katja, so lustig das klingt, aber kannst du einfach mal versuchen, das encoding wegzulassen? Ćndert das was?
+ 2
I don't see any problem. May be the file is encoded wrongly. please checkout the file correctly.
+ 2
HonFu, neee, hab schon versucht, bringt einfach nichtsš
+ 2
Ja, wie's auf dem Screen aussieht, muss leider nicht unbedingt was heiĆen.
+ 2
HonFu
sehe ich doppelt?
jeder Post 2x?
+ 2
Haha, jo, das ist in der Regel die Lƶsung. š¤£
Schƶn, dass es geklappt hat!
+ 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.)
+ 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 ).
+ 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
0
Edward ,you are right , it looks terribly now
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
0
M="german letter".encode("utf-8")