Last active
March 31, 2024 12:15
-
-
Save pointofpresence/48c0411dd798623b4272a6805205f83c to your computer and use it in GitHub Desktop.
Внутри цикла while используется оператор присваивания :=, который появился в Python 3.8. Он читает очередную строку из файла с помощью метода readline() и присваивает ее переменной line.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open(filename) as file: | |
while line := file.readline(): | |
print(line.rstrip()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment