Python ctypes:如何从stderr刷新输出?

Rya*_*yan 6 python windows dll ctypes

我已经使用python的ctypes编写了一些函数回调来访问DLL中的函数.使用fprintf到stderr,用于构建该DLL的代码中包含一些调试打印语句.但是,当我运行我的python代码时,我没有看到输出到stderr一致.我很少会看到它将stderr的输出刷新到我正在使用的控制台.我试过用"python -u foo.py"运行它,但这也无济于事.有什么建议?

Ign*_*ams 13

这是完全相同的stderr.

sys.stderr.flush()
Run Code Online (Sandbox Code Playgroud)