การเปลี่ยนนามสกุลไฟล์ใน Python

from pathlib import Path
p = Path('mysequence.fasta')
p.rename(p.with_suffix('.aln'))
# renamee is the file getting renamed, pre is the part of file name before extension and ext is current extension
pre, ext = os.path.splitext(renamee)
os.rename(renamee, pre + new_extension)