📜  来自绝对路径的 python 文件名 - Python 代码示例

📅  最后修改于: 2022-03-11 14:47:09.707000             🧑  作者: Mango

代码示例1
# Basic syntax:
import os
os.path.basename('/path/to/filename.txt')

# Example usage:
os.path.basename('/path/to/filename.txt')
--> filename.txt

# Note, to get the path instead of the filename, use:
os.path.dirname('/path/to/filename.txt')
--> /path/to