Answers for "open python read txt"

2

python read text file

# where f is the file alias
with open(r"pathtofile.txt", encoding='UTF8') as f:
    contents = f.read()
    print(contents)
Posted by: Guest on February-03-2022
47

python read file

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

Python Answers by Framework

Browse Popular Code Answers by Language