Skip to content
  • Tutorials
    • c programming
      • libraries
    • c++
    • Linux
    • Python
    • batch programming
    • Technology
  • IDE
  • Tools
get text from txt file python 1

get text from txt file python

June 16, 2022 by Anurag batra
with open ("data.txt", "r") as myfile:
    data = myfile.read().splitlines()

Here is what the above code is Doing:
1. Opening the file in read mode.
2. Reading the contents of the file into a variable called data.
3. Splitting the contents of the file into a list.

Categories Python Examples
Post navigation
python how to replace a certain string in text
python try else
© MyEduKit - 2022 . All Rights Reserved.