I want to change a.txt to b.kml.
a.txt
b.kml
Use os.rename:
os.rename
import os os.rename('a.txt', 'b.kml')
Usage:
os.rename('from.extension.whatever','to.another.extension')