Skip to content

SlayerLeon/HSE-Python-1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

479 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Week 1

Week 2

Week 3

Week 4

Week 5

Week 6

Чтение файла в Python

# Method 1. Читать файл построчно
infile = open('input.txt', 'r', encoding='utf-8')

data = infile.readlines()
print(type(data), data)
for row in data:
    a = list(row.split())
    print(a)

infile.close()
# Method 2
infile = open('input.txt', 'r', encoding='utf-8')

data = infile.read()
print(type(data), data)

infile.close()
# Method 3
import sys
data = sys.stdin.read()  # Command + D or Ctrl + D - для завершение чтение данных
print(type(data), data)
# Method 4
import sys
data = sys.stdin.readlines()  # построчно. Command + D or Ctrl + D - для завершение чтение данных
print(type(data))
print(data)

About

Tutoring. HSE Python course.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published