Python·100 questionsHow to work with files?SaveUpdated: 2026-08-31Answer•with open('file.txt', 'r', encoding='utf-8') as f:.•f.read() or for line in f:.•Modes: r, w, a, rb.•with automatically closes the file.•pathlib.Path — modern approach.Ask AI to clarifyWas this answer helpful?HelpfulNot helpfulSuggest an improvement