bash シェルから Python インラインを実行する方法 質問する

bash シェルから Python インラインを実行する方法 質問する

対話型インタープリターを起動したり、ファイルから読み取ったりせずに、シェルからコードを実行する Python 引数はありますか? 次のようなものです:

perl -e 'print "Hi"'

ベストアンサー1

これは機能します:

python -c 'print("Hi")'
Hi

マニュアルよりman python

   -c command
          Specify  the command to execute (see next section).  This termi-
          nates the option list (following options are passed as arguments
          to the command).

おすすめ記事