Answers for "how to call on a file in python"

1

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()
Posted by: Guest on December-03-2021
0

statement used to open a file in python

file_object  = open("filename", "mode")
Posted by: Guest on June-08-2020

Code answers related to "how to call on a file in python"

Python Answers by Framework

Browse Popular Code Answers by Language