Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to print to a file in python

#you do not have to create a text file in advance, this program will create the file if it does not exist.
whatever = ('this is what will be printed to your file')
sourceFile = open('demo.txt', 'w')
print(whatever, file = sourceFile)
sourceFile.close()
Source by www.journaldev.com #
 
PREVIOUS NEXT
Tagged: #print #file #python
ADD COMMENT
Topic
Name
7+1 =