python入门:sys.argv与optparse与argparse与getopt的区别

#optparse与argparse的区别:
Deprecated since version 3.2: The optparse module is deprecated and will not be developed further; development will continue with the argparse module.

Deprecated since version 2.7: The optparse module is deprecated and will not be developed further; development will continue with the argparse module.
#argparse与sys.argv的区别:
The argparse module makes it easy to write user-friendly command-line interfaces. The program defines what arguments it requires, and argparse will figure out how to parse those out of sys.argv. The argparse module also automatically generates help and usage messages and issues errors when users give the program invalid arguments.
#argparse 与getopt的区别:
The getopt module is a parser for command line options whose API is designed to be familiar to users of the C getopt() function. Users who are unfamiliar with the C getopt() function or who would like to write less code and get better help and error messages should consider using the argparse module instead.

你可能感兴趣的:(python)