- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
Python - 066 : Read from a file in python #python #pythonprogramming #pythontutorial
The read() method:
This function returns the bytes read as a string. If no n is specified, it then reads the entire file.
Example:
f = open("myfiles.txt", "r")
#('r’) opens the text files for reading only
print(f.read())
#The "f.read" prints out the data in the text file in the shell when run.
The readline() method:
This function reads a line from a file and returns it as a string. It reads at most n bytes for the specified n. But even if n is greater than the length of the line, it does not read more than one line.
f = open("myfiles.txt", "r")
print(f.readline())
The readlines() method:
This function reads all of the lines and returns them as string elements in a list, one for each line.
You can read the first two lines by calling readline() twice, reading the first two lines of the file:
f = open("myfiles.txt", "r")
print(f.readline())
print(f.readline())
Видео Python - 066 : Read from a file in python #python #pythonprogramming #pythontutorial канала The Digital Folks
This function returns the bytes read as a string. If no n is specified, it then reads the entire file.
Example:
f = open("myfiles.txt", "r")
#('r’) opens the text files for reading only
print(f.read())
#The "f.read" prints out the data in the text file in the shell when run.
The readline() method:
This function reads a line from a file and returns it as a string. It reads at most n bytes for the specified n. But even if n is greater than the length of the line, it does not read more than one line.
f = open("myfiles.txt", "r")
print(f.readline())
The readlines() method:
This function reads all of the lines and returns them as string elements in a list, one for each line.
You can read the first two lines by calling readline() twice, reading the first two lines of the file:
f = open("myfiles.txt", "r")
print(f.readline())
print(f.readline())
Видео Python - 066 : Read from a file in python #python #pythonprogramming #pythontutorial канала The Digital Folks
Комментарии отсутствуют
Информация о видео
24 июля 2023 г. 13:30:03
00:00:35
Другие видео канала











![linux command [ chown ] #shorts #linux #command #chown #bydubebox](https://i.ytimg.com/vi/44tOGeCVmbQ/default.jpg)
![Linux command [su] #shorts #linux #unix #commands #bydubebox](https://i.ytimg.com/vi/34_2bI3Pilc/default.jpg)








