相当于C++的STD::在Python中的阻塞?

2024-07-05 09:15:14 发布

您现在位置:Python中文网/ 问答频道 /正文

此C++代码将在终端上显示“加载文本”,主程序呈现图像。我知道这是因为std::clog。我一直在搜索,我认为subprocess模块可以帮助我在Python上复制它,但我完全不知道如何使用它。如何用Python编写这个代码?在

   std::stringstream progress_stream;
   progress_stream << "\r  progress .........................: "
                    << std::fixed << std::setw( 6 )
                    << std::setprecision( 2 )
                    << 100.0 * y / ( buffer_.v_resolution_ - 1 )
                    << "%";

    std::clog << progress_stream.str();

Tags: 模块代码图像文本终端streamfixedsubprocess