Created
June 4, 2015 14:11
-
-
Save manxisuo/c30248f439f078e8cc53 to your computer and use it in GitHub Desktop.
文件I/O
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
# 使用iter函数 | |
with open('a.txt', 'r') as file: | |
for l in iter(file.readline, ''): | |
print(l) | |
# file对象是iterable | |
with open('a.txt', 'r') as file: | |
for l in file: | |
print(l) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment