Answers for "read_file python"

47

python read file

with open("file.txt", "r") as txt_file:
  return txt_file.readlines()
Posted by: Guest on November-30-2020
0

python read file

fileName = "file_name.txt" #Here you need to write the file name as a string

openLike = "" #Here you need to write how do you want to open the file:
#"w": Write, "r": Read
openedFile = open("file_name.txt", openLike) #Here you open the file
fileText = openedFile.read() #This read all the file
openedFile.close() #Close the file
print(fileText) # Prints the file text
Posted by: Guest on January-04-2022

Python Answers by Framework

Browse Popular Code Answers by Language