Created
December 28, 2019 15:41
-
-
Save KuKuXia/1b9c92f367d39ca04fa2842d3287c9f3 to your computer and use it in GitHub Desktop.
利用迭代器实现数据的块输入
This file contains 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
""" | |
利用迭代器实现数据的块输入 | |
""" | |
CHUNK_SIZE = 50 | |
with open('somefile.txt') as f: | |
for chunk in iter(lambda: f.read(CHUNK_SIZE), ''): | |
print(chunk) | |
print('-' * 20) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment