Python Command Line Arguments

Jason Friedman jsf80238 at gmail.com
Wed Apr 12 22:33:04 EDT 2017


>
> I have this code which I got from https://www.tutorialspoint.
> com/python/python_command_line_arguments.htm The example works fine but
> when I modify it to what I need, it only half works. The problem is the
> try/except. If you don't specify an input/output, they are blank at the end
> but it shouldn't be.
>
> import getopt
> import sys
>

Hello Ian,
I am guessing you are wanting to parse command-line arguments rather than
particularly wanting to use the getopt module.
If I am correct you might want to spend your time instead learning the
argparse module:
https://docs.python.org/3/library/argparse.html
https://docs.python.org/3/howto/argparse.html



More information about the Python-list mailing list