Checking the number of command line arguments in python

前端 未结 2 2318
忘掉有多难
忘掉有多难 2021-02-20 10:24

I\'m new to python. Still getting my feet wet. I\'m trying to do something like this:

import sys

if ((len(sys.argv) < 3 or < len(sys.argv > 3)):
             


        
2条回答
  •  遥遥无期
    2021-02-20 11:01

    Use sys.exit() to exit from a script.

    import sys
    
    if len(sys.argv) != 3:
        print """\
    This script will compare two files for something
    and print out matches
    
    Usage:  theScript firstfile secondfile
    """
        sys.exit(0)
    

提交回复
热议问题