我从XML读取路径列表,路径包含不规则元素使用
由将其内部翻译的证书申请。
当前的路径字符串对我来说毫无用处,我希望对其进行归一化处理。
example:
path = "%personal%\new_lcation\%vendorlibs%\generated"
# split this to a list
omponents = path.split(os.sep)
# replace elemnts 0,2
components[0]="c:\ProgramFiles"
components[2]="somthing"
如何将所有内容现在都加入标准路径字符串?
谢谢
最佳答案
os.path.join(*components)
。 os.path.join
documentation。
关于python - python -从一个 split 的建立新的路径字符串,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11180337/