# argparse

```python
import argparse

# ArgumentParser
parser = argparse.ArgumentParser()
parser.add_argument('-all', action="store_true")
parser.add_argument('-task', help='==> your task')
parser.add_argument('-file', help='==> file path')

args = parser.parse_args()

# 使用 -h 時會顯示 help 內容
```

參考資料：\
[https://medium.com/@dboyliao/python-超好用標準函式庫-argparse-4eab2e9dcc69](https://medium.com/@dboyliao/python-%E8%B6%85%E5%A5%BD%E7%94%A8%E6%A8%99%E6%BA%96%E5%87%BD%E5%BC%8F%E5%BA%AB-argparse-4eab2e9dcc69)

```
設定action="store_true"，表示若使用該參數時則帶入True
#python test.py -c => c是true（觸發）
#python test.py => c是false（無觸發）
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://stb11816.gitbook.io/python_note/web/argparse.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
