Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to open a file with python

x = open("filename.txt", "r")
print(x.read()) #if file is a txt file this will print the text
#Make sure the file is in the same directory as were your python file is opened in.
#you can also make a var out of your text by doing:
var = x.read() #or 
var = open("filename.txt", "r").read()
Source by www.pythontutorial.net #
 
PREVIOUS NEXT
Tagged: #open #file #python
ADD COMMENT
Topic
Name
8+9 =