python去除扩展名的实例讲解
获取不带扩展名的文件的名称: import os printos.path.splitext(path_to_file)[0] from os.path import basename # now you can call it directly with basename print basename(/a/b/c.txt) >>>base=os.path.basename('/root/dir/sub/file.ext') >>> base 'file.ext' >>> os.path.splitext(base) ('file', '.ext') >>> os.path.sp
用户评论