我想将帮助文档写入md文件
>>> import re
>>> import contextlib
>>> file = open("regex_help.md", "w")
>>> with contextlib.redirect_stdout(file):
... help(re)
但是,“ regex_help.md”为空
>>> os.stat("regex_help.md").st_size
0
我记得它昨天工作了。
>>> file.flush()
>>> os.stat("regex_help.md").st_size
1
file.flush()无法正常工作
为什么偶尔会失败?