You can also save the ASCII text representation of
objects to a plain text file by simply opening
a file in write mode and writing the string representation
of the object (you can write many objects this way as well).
When you're done writing objects, close the file.
sage: R.<x,y> = PolynomialRing(QQ,2)
sage: f = (x+y)^7
sage: o = open('file.txt','w')
sage: o.write(str(f))
sage: o.close()