Naming a file

Matthias Bläsing matthias.blaesing at rwth-aachen.de
Sat Jan 19 23:20:47 CET 2008


Am Sat, 19 Jan 2008 14:14:30 -0800 schrieb snoylr:

> For example if the variable is 105Markum
> 
> What statement do I need to create a file name 105Markum.txt?

filename_base = '105Markum'
filename = '%s.txt' % filename_base
f = open(filename, 'w')
f.write(<whatever you wanna write)
f.close

Should do it for you

Matthias



More information about the Python-list mailing list