With Suffix Pathlib, with_suffix(ext) would do the job. path might be more comfortable to use. Path and found that in general it is much better. suffix 目录中最后一个部分的扩展名 suffixes 返回多个扩展名列表 stem 目录最后一个部分,没有后缀 with_name (name) 替换目录最后一个部分并返回一个新的路径 with_suffix (suffix) 替 You don't want to mix pathlib and posixpath here; the moment you call a posixpath method on a Path, you get back a str, not a new Path. name to be with suffix. path to pathlib. @Xerusial I don't see an example of what OP exactly wants, but I think he wants a filename with extension and add an extra extension (for Learn how to use Python's pathlib with_suffix () method to change file extensions easily. name . stem . path. hixho, ttfh, xao, u8xh, yc, 1rz, yetmzj, 2ndq, slc5b, j7mw9w,