Linux截取路徑中的文件名並去後綴

假設一個文件的路徑名爲:「/home/Project/Myjob/hello.txt」,並且路徑和文件名都不是固定的。如何獲得hello.txt這段字符串呢?數組 1、使用basename()函數   import os.path  filePath=「/home/Project/Myjob/hello.txt」  x = os.path.basename(filePath)  print x
相關文章
相關標籤/搜索