获取没有扩展名的文件名称:
import os
print(os.path.splitext("path_to_file")[0])
滚动吧:
>>> import os
>>> base=os.path.basename('/root/dir/sub/file.ext')
>>> base
'file.ext'
>>> os.path.splitext(base)
('file', '.ext')
>>> os.path.splitext(base)[0]
'file'
>>> print(os.path.splitext(os.path.basename("hemanth.txt"))[0])
hemanth