Newbie: print-to-file-Syntax
Sabine Richter
sabine at textraeume.de
Sat May 18 14:14:25 EDT 2002
Hello,
I looked the syntax up in the python doc, but nevertheless, I don't
understand it. What's wrong?
PROT=open("c:\\existing_dir\\prot.txt",'w')
PROT.write("Written String")
print >> PROT "Printed String"
print PROT "Printed String"
PROT.close()
--> Written String has been written. But for the print-Statements I get
a syntax error message
And a second question:
Is it possible to write:
PROT=None
print... print-to-file-syntax
Later, I want to print to file, but now I want to print to STDOUT.
The doc says: If the first expression evaluates to None, then sys.stdout
is used as the file for output.
Thanks in advance
Sabine
More information about the Python-list
mailing list