Suppose from index.py with CGI, I have post file foo.fasta to display file. I want to change foo.fasta's file extension to be foo.aln in display file. How can I do it?
index.py
foo.fasta
foo.aln
An elegant way using pathlib.Path:
from pathlib import Path p = Path('mysequence.fasta') p.rename(p.with_suffix('.aln'))
2.1m questions
2.1m answers
60 comments
57.0k users