1
我有以下代碼來執行普通的文本文件的閱讀通告:Python的`with`聲明和文件讀取發電機
def file_reader(filename):
with open(filename, 'rb') as f:
while True:
for line in f:
yield line.strip()
f.seek(0)
文件時,如果將用戶按Ctrl+C
某處時程序執行關閉我想知道?
相關:[與發電機中的語句一起使用明智嗎?](https://stackoverflow.com/q/29040534) –