国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

python - tornado中使用parse_command_line(final=False) 沒能理解final是做什么的

瀏覽:111日期:2022-09-15 08:55:13

問題描述

大概知道parse_command_line是用來解析命令行的,但是不理解里面的final參數是作什么的。順便咨詢一下學習tonardo的學習資源(知道官方文檔是最好的)和書籍

問題解答

回答1:

通過這樣,找到源代碼,請自己看方法文檔

If final is False, parse callbacks will not be run.

This is useful for applications that wish to combine configurationsfrom multiple sources.

python - tornado中使用parse_command_line(final=False) 沒能理解final是做什么的

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 namein `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 configurationsfrom multiple sources.'''if args is None: args = sys.argvremaining = []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 編程
相關文章:
主站蜘蛛池模板: 保德县| 青阳县| 墨竹工卡县| 宜都市| 龙南县| 长汀县| 西城区| 高州市| 新民市| 凤凰县| 萨嘎县| 定南县| 河北区| 章丘市| 醴陵市| 洛隆县| 古丈县| 沂水县| 利辛县| 桃园市| 察雅县| 木兰县| 桃源县| 胶州市| 固始县| 马龙县| 黄龙县| 丽水市| 益阳市| 延津县| 定安县| 溆浦县| 云梦县| 津市市| 聂拉木县| 金乡县| 公主岭市| 万源市| 杭锦后旗| 扶绥县| 武川县|