os.path.dirname
时间: 2023-11-23 17:36:57 浏览: 120
浅析python3中的os.path.dirname(__file__)的使用
os.path.dirname() is a function in Python's built-in os module that returns the directory name of a given path.
For example, if we have a file path "/usr/local/bin/python", `os.path.dirname("/usr/local/bin/python")` would return "/usr/local/bin".
This function can be useful for extracting the directory path of a file or folder to perform operations on it, such as creating a new file in the same directory.
阅读全文