Search code examples
pythonencodingutfcyrillic

Coding issue in folder path


I have a folder path which has some cyrillic letter which stop the process of another script. I need to get a folder path without cyrillic letters but python doesn't return it.

The folder is C:\Users\PereverzevPV\Documents\Инв.

I have:

import os
folder = os.getcwd()
print folder

The output is empty no matter what coding I set. I need to get

'C:\\Users\\PereverzevPV\\Documents\\\xd0\x98\xd0\xbd\xd0\xb2'

Solution

  • try this :

    # coding: UTF-8
    
    import os
    
    os.getcwd().encode('utf-8').decode('utf-8')
    

    We Need To Encode The CWD then to Decode Him