我在Q_GIS中有一些Python代码可以打开对象。我的问题是目录中有一个无法编码的字符(下划线类似字符)。错误是:
追溯(最近一次通话最后一次):文件“”,第1行,UnicodeEncodeError:'ascii'编解码器无法对位置10处的字符u'\ u2013'进行编码:序数不在范围内(128)
我的小代码是:
from os import startfile;
proj = QgsProject.instance();
UriFile = str(proj.fileName());
img = '[% "pad" %]';
Path = str(os.path.dirname(UriFile));
startfile(Path+img)
Run Code Online (Sandbox Code Playgroud)
由于我的编程技巧很少,因此请您帮助我在此小代码中添加一些代码以解决该问题。