我正在编写一些使用Onclick事件获取一些文件路径的代码。我需要确保这些文件路径是文本,以确保它们是正确的,这样我的其余代码才能运行。现在我想我得到的文件路径是unicode。基本上我需要这个:u"File\location\extra\slash"
成为这样:
^{pr2}$
我该怎么做?我还没能找到真正能成功做到这一点的人,而文档中也没有这方面的任何例子。我无法更改给我文件路径Onclick事件的函数的工作方式。在
以下是相关代码:class SetLayer(object):
"""Implementation for leetScripts_addin.button2 (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
self.a = pythonaddins.GetSelectedCatalogWindowPath()
print self.a
#code split up path here
self.b = os.path.split(str(self.a))
self.c = self.b[0]
self.d = os.path.split(self.c)
self.e = (self.b[1])
self.f = (self.d[1])
self.g = (self.d[0])