Python - How to read a file in Python? - Learn Python on BeingSkilled

To read a file in Python, you need to use the function "open()" with variables Path Name, the mode such as r for writing, encoding such as UTF-08. 

data_read = open('../../../Downloads/file-name.txt', "r")

 

Leave a comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.