私はいくつかのコマンドを実行するbashスクリプトを書いています。以下は抜粋です。
echo -en "\nStage 2: Launching Bot\e[1;0m\n"
python main.py
の出力には、python main.py
最初に複数行の警告がたくさん含まれています。 「[Bot]」で始まる出力行のみを表示するにはどうすればよいですか(またはこれらの警告を出力しない方法はありますか?)。
ベストアンサー1
警告を抑制するためにPythonモジュールを使用していますwarnings
。
# this should be at the very top of the file
import warnings
warnings.filterwarnings("ignore")
# the rest of the code, including all other import statements, goes here
今はエラーと私が出力したいものの両方を印刷します。