python 获取文件名称以及文件后缀

code

>>> import os
>>> dir, suffix = os.path.splitext("test.pdf")
>>> dir
'test'
>>> suffix
'.pdf'
>>> dir, suffix = os.path.splitext("/root/test.pdf")
>>> dir
'/root/test'
>>> suffix
'.pdf'
>>> 

原文地址:https://www.cnblogs.com/sea-stream/p/13518656.html