Hello, I'm pretty new to Python, so please bear over with me, if I ask any beginner's questions.
I'm trying to work on multiple files in a folder, my code seem to be working. But I have some encoding problem. I get the "ufeff" including in some of my printed text.
I have saved kall the files with the UTF-8 format. And used "encoding = "utf-8" in my code. It always worked before.
Can anyone identify why it doesn't work or how I could maybe alter my code (the placement of "encoding = "utf-8" for example.
I'm trying to work on multiple files in a folder, my code seem to be working. But I have some encoding problem. I get the "ufeff" including in some of my printed text.
I have saved kall the files with the UTF-8 format. And used "encoding = "utf-8" in my code. It always worked before.
Can anyone identify why it doesn't work or how I could maybe alter my code (the placement of "encoding = "utf-8" for example.
Import os path = "/Users/nikolajkorsgaard/Documents/Eksamenen" for filename in os.listdir(path): with open(filename, "r", encoding = "utf-8") as f: if filename.endswith(".txt"): for line in f: print(line.split())