python提供getopt模块解析命令行参数。
官方文档地址:https://docs.python.org/2.7/library/getopt.html
我目前使用的还是python 2.7。其他版本的文档在官网也很容易找到。
官网文档写的十分好,例子也很清晰,不赘述。
有句话需要注意下,没看文档前被这个问题困扰了很久:
Long options on the command line can be recognized so long as they provide a prefix of the option name that matches exactly one of the accepted options. For example, if long_options is ['foo', 'frob'], the option --fo will match as --foo, but --f will not match uniquely, so GetoptError will be raised.
本文详细介绍了Python中用于解析命令行参数的getopt模块,包括其使用方法、长选项匹配规则及常见错误处理。
1113

被折叠的 条评论
为什么被折叠?



