[Tutor] multiple file output

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Mon Sep 8 08:38:19 EDT 2003



On Mon, 8 Sep 2003, Jimmy verma wrote:


> I want to write two strings in two different files. Like i want the user
> to run the program by specifying the name of the program on command line
> and want to generate a few files based on the strings of information i
> have in the code.

Hi Jimmy,

Not a problem --- we'll want to use the 'open()' builtin function again,
but this time, we want to tell it to open the file in 'write' mode.  For
example:

###
f = open('foobar.txt', 'w')
f.write("Hello world!\n")
###


Hope this helps!




More information about the Tutor mailing list