mirror of
https://github.com/Brandon-Rozek/website.git
synced 2024-11-22 08:16:29 -05:00
Fixed typo in URL and added default example
This commit is contained in:
parent
ecc22fcb52
commit
7f4a98b474
1 changed files with 4 additions and 0 deletions
|
@ -3,6 +3,8 @@ title: "Python Argument Parser"
|
||||||
date: 2022-05-16T17:07:06-04:00
|
date: 2022-05-16T17:07:06-04:00
|
||||||
draft: false
|
draft: false
|
||||||
tags: ["Python"]
|
tags: ["Python"]
|
||||||
|
aliases:
|
||||||
|
- /blog/python-argpase/
|
||||||
math: false
|
math: false
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -16,6 +18,8 @@ parser = argparse.ArgumentParser(description="Description to show in help")
|
||||||
parser.add_argument("pos_arg1", type=str, help="Required positional argument")
|
parser.add_argument("pos_arg1", type=str, help="Required positional argument")
|
||||||
parser.add_argument("--flag1", type=str, help="Optional flag argument")
|
parser.add_argument("--flag1", type=str, help="Optional flag argument")
|
||||||
parser.add_argument("--flag2", type=int, required=True, help="Required flag argument")
|
parser.add_argument("--flag2", type=int, required=True, help="Required flag argument")
|
||||||
|
parser.add_argument("--flag3", type=int, default=0, help="Optional flag argument \
|
||||||
|
with default value of 0")
|
||||||
args = vars(parser.parse_args())
|
args = vars(parser.parse_args())
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in a new issue