How do I open a python file?

Như Quỳnh

New member
How do I open a python file?
Answer
Python File Open
  1. f = open(“demofile.txt”, “r”) print(f.read()) …
  2. Open a file on a different location: f = open(“D:\myfileswelcome.txt”, “r”) …
  3. Return the 5 first characters of the file: …
  4. Read one line of the file: …
  5. Read two lines of the file: …
  6. Loop through the file line by line: …
  7. Close the file when you are finish with it:
 

Tìm kiếm

Back
Top