How to rename a file using Python

zjm1126 picture zjm1126 · Mar 22, 2010 · Viewed 404.5k times · Source

I want to change a.txt to b.kml.

Answer

YOU picture YOU · Mar 22, 2010

Use os.rename:

import os

os.rename('a.txt', 'b.kml')