Is there a way to deal with greek characters in python?

403 Views Asked by At

Is there a way i can get this code working in python?

import os
import subprocess

path = "/home/workspace/test/2014"

for file in os.listdir(path):
    //print(file)
    subprocess.call(["pdftotext %s" % file])

I have a path where i store all my pdf files. Every file name has greek characters for example (ΤΕΣΤ_1_2014). When i run the above code i get an error like this

 UnicodeDecodeError: 'ascii' codec can't decode byte 0xce in position 0: ordinal not in range(128) 

What's the difference between encode and decode for string? I have used both in the last line when i am creatin the txt file but none of them works Please help!

0

There are 0 best solutions below