First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
sage: s = str(2^1000)
sage: f = open('filename.txt', 'w')
sage: f.write(s)
sage: f.close()
click to hide/show revision 2
No.2 Revision

sage: s = str(2^1000) sage: f = open('filename.txt', 'w') sage: f.write(s) sage: f.close() f.close()

or using a with-statement which closes the file for you:

sage: with open('filename.txt', 'w') as f:
....:     f.write(str(2^1000))
click to hide/show revision 3
No.3 Revision

sage: s = str(2^1000) sage: f = open('filename.txt', 'w') sage: f.write(s) sage: f.close()

or using a with-statement which closes the file for you:

sage: with open('filename.txt', 'w') as f:
....:     f.write(str(2^1000))
click to hide/show revision 4
No.4 Revision

sage: s = str(2^1000) sage: f = open('filename.txt', 'w') sage: f.write(s) sage: f.close()

or using a with-statement which closes the file for you:

sage: with open('filename.txt', 'w') as f:
....:     f.write(str(2^1000))
click to hide/show revision 5
No.5 Revision

:

sage: s = str(2^1000)
 sage: f = open('filename.txt', 'w')
 sage: f.write(s)
 sage: f.close()

f.close()

or using a with-statement which closes the file for you:

sage: with open('filename.txt', 'w') as f:
....:     f.write(str(2^1000))