python tornado中使用parse_command_line(final=False) final有何作用?,,大概知道parse_co
python tornado中使用parse_command_line(final=False) final有何作用?,,大概知道parse_co
大概知道parse_command_line是用来解析命令行的,但是不理解里面的final参数是作什么的。顺便咨询一下学习tonardo的学习资源(知道官方文档是最好的)和书籍
通过这样,找到源代码,请自己看方法文档
If final is False, parse callbacks will not be run.
This is useful for applications that wish to combine configurationsfrom multiple sources.
def parse_command_line(self, args=None, final=True): """Parses all options given on the command line (defaults to `sys.argv`). Note that ``args[0]`` is ignored since it is the program name in `sys.argv`. We return a list of all arguments that are not parsed as options. If ``final`` is ``False``, parse callbacks will not be run. This is useful for applications that wish to combine configurations from multiple sources. """ if args is None: args = sys.argv remaining = [] for i in range(1, len(args)): # All things after the last option are command line arguments if not args[i].startswith("-"): remaining = args[i:] break if args[i] == "--": remaining = args[i + 1:] break arg = args[i].lstrip("-") name, equals, value = arg.partition("=") name = self._normalize_name(name) if name not in self._options: self.print_help() raise Error('Unrecognized command line option: %r' % name) option = self._options[name] if not equals: if option.type == bool: value = "true" else: raise Error('Option %r requires a value' % name) option.parse(value) if final: self.run_parse_callbacks() return remaining
编橙之家文章,
相关内容
- Python 《笨办法学python》38题keyerror问题,,我在敲《笨办
- Python jinja2转义img、code之类标签转义有何方法,pythonj
- 模板渲染前端js和后端python哪个更好,前端js后端pytho
- Python安装bloomfilter过滤器报fatal erroe错误怎么解决,bl
- python如何解决不同时区服务器时间问题,python时区,我们
- python xlrd模块 获得单元格格式信息,pythonxlrd,我想获取
- virtualenv中的包除了pip 、easy_install外,还有其它安装方法
- Python想创建一个相对安全的unique session id应该怎么写,
- ansible tower开发前端框架是用什么呢?,ansibletower,问下
- python使用subprocess出现问题,pythonsubprocess,知网的下载工
评论关闭