自定义的windows路径中分隔符 ( \ ) 转linux路径分隔符 ( / )

    # 将windows路径中的分隔符\转换为unix(linux)的分隔符/
    @staticmethod
    def transform_separator(windows_path):
        linux_path = ''
        if windows_path != '':
            path_list = windows_path.split('\\')
            linux_path = '/'.join(path_list)
        else:
            print("it is null")
        return linux_path

参考了https://blog.csdn.net/talk_8/article/details/82055852

并将代码封装为静态方法。 

猜你喜欢

转载自blog.csdn.net/qq_27361945/article/details/83650912
今日推荐