0

I'm just new to Python and I want to ask:

How can I process input values from command line with Python? For example:

./mathpy.py --plus 2 5

result: 7

or

./mathpy.py --max 2 5

result: 5

Some examples would be great.

Thanks a lot.

nguyenvu
  • 77
  • 4
  • 1
    https://docs.python.org/3/library/argparse.html – idjaw Nov 02 '15 at 03:06
  • 1
    Next time, use Google to search for your question, and relevant answers on SO will appear at the top. Also, while you are composing your question, a list entitled **Questions that may already have your answer** shows up with potentially relevant questions. **Use that list** and open up the suggested questions in new tabs. This site has been around for over 6 years, if you suspect a question has already been asked, it probably has. Duplicates like this just waste time and effort. – MattDMo Nov 02 '15 at 03:52

1 Answers1

0

Please, take a look at argparse module:

https://docs.python.org/3/library/argparse.html

Andrés Pérez-Albela H.
  • 4,003
  • 1
  • 18
  • 29