Python
 Computer >> コンピューター >  >> プログラミング >> Python

Pythonのコマンドライン引数


多くのプログラムを実行して、実行方法に関する基本的な情報を提供できます。 Pythonでは、-h −

を使用してこれを行うことができます
$ python -h
usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Options and arguments (and corresponding environment variables):
-c cmd : program passed in as string (terminates option list)
-d : debug output from parser (also PYTHONDEBUG=x)
-E : ignore environment variables (such as PYTHONPATH)
-h : print this help message and exit
[ etc. ]

さまざまなオプションを受け入れるようにスクリプトをプログラムすることもできます。コマンドライン引数は高度なトピックであり、Pythonの残りの概念を理解したら、少し後で学習する必要があります。


  1. C#のコマンドライン引数

    コマンドラインで引数を渡したい場合は、C#でコマンドライン引数を使用します- c#でプログラムを作成すると、static void mainが使用され、その中の引数を確認できます。 class HelloWorld {    static void Main(string[] args) {       /* my first program in C# */       Console.WriteLine("Hello World");       Consol

  2. コマンドラインを介したPythonMatplotlibによるインタラクティブなプロット

    インタラクティブなプロットを取得するには、フィギュアをアクティブにする必要があります。 plt.ioff()の使用 およびplt.ion() 、プロットを使用してインタラクティブなアクションを実行できます。 Ipythonを開きます シェルを選択し、シェルで次のコマンドを入力します。 例 In [1]: %matplotlib auto Using matplotlib backend: GTK3Agg In [2]: import matplotlib.pyplot as In [3]: fig, ax = plt.subplots() # Diagram will pop up.