I have a little Python code in Q_GIS which opens objects. The problem I have is that in the directory there is a character (underscore like character) that can not be encoded. The error is:
Traceback (most recent call last): File "", line 1, in UnicodeEncodeError: 'ascii' codec can't encode character u'\u2013' in position 10: ordinal not in range(128)
My little code is:
from os import startfile;
proj = QgsProject.instance();
UriFile = str(proj.fileName());
img = '[% "pad" %]';
Path = str(os.path.dirname(UriFile));
startfile(Path+img)
Because of my little programming skills, I ask you to help me add some code in this little code to overcome the problem.