Created
April 8, 2022 11:36
-
-
Save pointofpresence/26851fa07326398ac3acdaf6638d01d6 to your computer and use it in GitHub Desktop.
Python print to file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open('out.txt', 'w') as f: | |
print('Filename:', filename, file=f) # Python 3.x | |
print >> f, 'Filename:', filename # Python 2.x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment