Opening and Closing Files
open() and close() functions
Interview Relevant: Basic file I/O
Opening Files
Use the built-in open() function.
Code Examples
python
1f = open("file.txt", "r")
2content = f.read()
3f.close() # Don't forget this!open() and close() functions
Use the built-in open() function.
1f = open("file.txt", "r")
2content = f.read()
3f.close() # Don't forget this!Ask about the topic