Get relative path

    0

    11

    Python public recipes

    The os.path.relpath() function returns the relative path to a file or directory. In this case, it returns the path to the /etc/passwd file.

    Shortcut: file.path.relative

    import os
    
    os.path.relpath(directory, base_directory)
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.