Python sys.argv and argparse

I was looking for ways to add argument values ​​to a script when I run it from the command line. Two packages found that seem to do this are sys.argv and argparse.

I would also like to add some help function if possible.

Can someone explain the difference between the two, and maybe it will be easier for someone to start?

+4
source share
2 answers

sys.argv is just a list of command line arguments.

argparse- A full-featured command line parser that typically parses sys.argvand returns data much easier to use.

- , script, , . python python 3 (getopt, optparse argparse) argparse.

+9

argparse . arg , , -, , argparse .

: https://docs.python.org/2/howto/argparse.html

, .

+2

Source: https://habr.com/ru/post/1628522/


All Articles