Read from a file in Python

Опубликовано: 29 Сентябрь 2024
на канале: Python Morsels
568
34

To work with a text file in Python, you can use the built-in open function, which gives you back a file object. Reading from and writing to text files is an important skill.

Read an article version of this video at https://pym.dev/how-read-text-file/

Find more Python screencasts at https://pym.dev/screencasts/

00:00 Opening and reading a text file in Python
00:40 Closing files manually using the close method
01:30 Using a with block to automatically close the file
02:26 Recap: use the open function and a "with" block to read from a file