iNTERFACEWARE Products Manual > Learning Center > Learning Python > File Reading and Writing > Writing to a File |
|
Looking for Iguana v.5 or v.6? Learn More or see the Help Center.
To write to a file, use the write() function. This function takes a string as its parameter, and writes the string to its associated output file. For example, here is a simple program that opens a file for writing, and then writes two strings to the file:
Note that this program writes the two strings to the same output line. The output file looks like this:
To write the strings on separate lines, add a newline character, represented by \n, to the end of the first string:
|