前言
在使用jupyter notebook时,使用ctypes调用C动态库API。C库的printf不能输出到jupyter notebook的终端。
参考 https://discourse.jupyter.org/t/when-calling-printf-by-ctypes-jupyter-does-not-show-output-from-printf/7319
简单解释
安装wurlitzer
pip install wurlitzer
使用
在运行你的python代码,使用ctypes之前,在jupyter notebook的cell中调用以下命令
%load_ext wurlitzer
运行你的ctypes相关代码,会发现,C库的printf打印会输出到jupyter notebook终端上