[Tutor] File extension change

Alan Gauld alan.gauld at btinternet.com
Wed Feb 3 04:25:11 EST 2016

On 02/02/16 17:46, Chelsea G wrote:

> ...but then in the def json_output instead of having the
> filename which i have now is 'test.txt' I want to have weekly_20160102.txt
> same naming convention as the csv file i am inputting. 

Take a look at the os.path module documentation.
There are several functions for manipulating
filenames including splitting and joining
the various constituent parts (basename,
extension, path etc).

You might decide to use os.rename() too.

Alan G
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:

More information about the Tutor mailing list