Writing to file

Neil Schemenauer nas at arctrix.com
Fri Oct 13 04:01:10 EDT 2000


On Fri, Oct 13, 2000 at 05:36:27PM +0300, j wrote:
> How can i write string "test string" into file "test.txt".

    f = open("test.txt", "w")
    f.write("test string")
    f.close()

> How can i print
> i am a "monkey"

    print 'i am a "monkey"'

or if you don't want the newline:

    import sys
    sys.stdout.write('i am a "monkey"')




More information about the Python-list mailing list