zoukankan      html  css  js  c++  java
  • os.path.join()函数

     os.path.join()函数主要用于将多个路径组合后返回

    语法:os.path.join(path1[,path2[,path3[,...[,pathN]]]])

    返回值:将多个路径组合后返回

    注意:从倒数第一个以‘/’开头的参数开始拼接,之前的参数全部丢弃。

       以‘/’结尾的,以及参数中间有‘/’的,斜杠仅作为参数的一部分。

    代码示例:

    import os
    
    print os.path.join('111','222','333')     #111/222/333
    print os.path.join('/111','222','333')    #/111/222/333
    print os.path.join('/111','/222','333')   #/222/333
    
    print os.path.join('/111','/222','/333')  #/333
    
    print os.path.join('111','222','/333')     #/333
    print os.path.join('111','/222','/333')    #/333
    print os.path.join('/111','/222','/333')   #/333
    
    print os.path.join('111/','222','333')     #111/222/333
    print os.path.join('111/','222/','333')    #111/222/333
    print os.path.join('111/','222/','333/')   #111/222/333/
    
    print os.path.join('111','222','333/')     #111/222/333/
    print os.path.join('111','222/','333/')    #111/222/333/
    print os.path.join('111/','222/','333/')   #111/222/333/
    
    print os.path.join('111','222','./333')    #111/222/./333
  • 相关阅读:
    Java 数组算法列题解析
    Java数组总结
    go实现汉诺塔
    go实现归并排序
    css清除浮动深度解析
    jquery阻止事件冒泡
    java
    getComputedStyle/currentStyle/style之间的爱恨情仇
    js基础总结
    元素堆叠问题、z-index、position
  • 原文地址:https://www.cnblogs.com/mcladyr/p/13826349.html
Copyright © 2011-2022 走看看