当前位置: 首页>>代码示例>>Python>>正文


Python DictMixin.items方法代码示例

本文整理汇总了Python中UserDict.DictMixin.items方法的典型用法代码示例。如果您正苦于以下问题:Python DictMixin.items方法的具体用法?Python DictMixin.items怎么用?Python DictMixin.items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserDict.DictMixin的用法示例。


在下文中一共展示了DictMixin.items方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: write

# 需要导入模块: from UserDict import DictMixin [as 别名]
# 或者: from UserDict.DictMixin import items [as 别名]
def write(self, f):
        """ Write namespace as INI file.

        :param f: File object or path to file.

        """
        if isinstance(f, str):
            f = io.open(f, 'w', encoding='utf-8')

        if not hasattr(f, 'read'):
            raise AttributeError("Wrong type of file: {0}".format(type(f)))

        NS_LOGGER.info('Write to `{0}`'.format(f.name))
        for section in self.sections.keys():
            f.write('[{0}]\n'.format(section))
            for k, v in self[section].items():
                f.write('{0:15}= {1}\n'.format(k, v))
            f.write('\n')
        f.close() 
开发者ID:AtomLinter,项目名称:linter-pylama,代码行数:21,代码来源:inirama.py

示例2: __reduce__

# 需要导入模块: from UserDict import DictMixin [as 别名]
# 或者: from UserDict.DictMixin import items [as 别名]
def __reduce__(self):
        items = [[k, self[k]] for k in self]
        tmp = self.__map, self.__end
        del self.__map, self.__end
        inst_dict = vars(self).copy()
        self.__map, self.__end = tmp
        if inst_dict:
            return (self.__class__, (items,), inst_dict)
        return self.__class__, (items,) 
开发者ID:ME-ICA,项目名称:me-ica,代码行数:11,代码来源:_ordered_dict.py

示例3: __repr__

# 需要导入模块: from UserDict import DictMixin [as 别名]
# 或者: from UserDict.DictMixin import items [as 别名]
def __repr__(self):
        if not self:
            return '%s()' % (self.__class__.__name__,)
        return '%s(%r)' % (self.__class__.__name__, self.items()) 
开发者ID:ME-ICA,项目名称:me-ica,代码行数:6,代码来源:_ordered_dict.py

示例4: __eq__

# 需要导入模块: from UserDict import DictMixin [as 别名]
# 或者: from UserDict.DictMixin import items [as 别名]
def __eq__(self, other):
        if isinstance(other, OrderedDict):
            return len(self)==len(other) and self.items() == other.items()
        return dict.__eq__(self, other) 
开发者ID:ME-ICA,项目名称:me-ica,代码行数:6,代码来源:_ordered_dict.py

示例5: __eq__

# 需要导入模块: from UserDict import DictMixin [as 别名]
# 或者: from UserDict.DictMixin import items [as 别名]
def __eq__(self, other):
        if isinstance(other, OrderedDict):
            if len(self) != len(other):
                return False
            for p, q in  zip(self.items(), other.items()):
                if p != q:
                    return False
            return True
        return dict.__eq__(self, other) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:11,代码来源:ordereddict.py

示例6: iteritems

# 需要导入模块: from UserDict import DictMixin [as 别名]
# 或者: from UserDict.DictMixin import items [as 别名]
def iteritems(self, raw=False):
        """ Iterate self items. """

        for key in self:
            yield key, self.__getitem__(key, raw=raw) 
开发者ID:AtomLinter,项目名称:linter-pylama,代码行数:7,代码来源:inirama.py

示例7: __init__

# 需要导入模块: from UserDict import DictMixin [as 别名]
# 或者: from UserDict.DictMixin import items [as 别名]
def __init__(self, **default_items):
        self.sections = OrderedDict()
        for k, v in default_items.items():
            self[self.default_section][k] = v 
开发者ID:AtomLinter,项目名称:linter-pylama,代码行数:6,代码来源:inirama.py

示例8: parse

# 需要导入模块: from UserDict import DictMixin [as 别名]
# 或者: from UserDict.DictMixin import items [as 别名]
def parse(self, source, update=True, **params):
        """ Parse INI source as string.

        :param source: Source of INI
        :param update: Replace already defined items

        """
        scanner = INIScanner(source)
        scanner.scan()

        section = self.default_section
        name = None

        for token in scanner.tokens:
            if token[0] == 'KEY_VALUE':
                name, value = re.split('[=:]', token[1], 1)
                name, value = name.strip(), value.strip()
                if not update and name in self[section]:
                    continue
                self[section][name] = value

            elif token[0] == 'SECTION':
                section = token[1].strip('[]')

            elif token[0] == 'CONTINUATION':
                if not name:
                    raise SyntaxError(
                        "SyntaxError[@char {0}: {1}]".format(
                            token[2], "Bad continuation."))
                self[section][name] += '\n' + token[1].strip() 
开发者ID:AtomLinter,项目名称:linter-pylama,代码行数:32,代码来源:inirama.py

示例9: __eq__

# 需要导入模块: from UserDict import DictMixin [as 别名]
# 或者: from UserDict.DictMixin import items [as 别名]
def __eq__(self, other):
        if isinstance(other, OrderedDict):
            return len(self)==len(other) and \
                   all(p==q for p, q in  zip(self.items(), other.items()))
        return dict.__eq__(self, other) 
开发者ID:gkudos,项目名称:qgis-cartodb,代码行数:7,代码来源:ordered_dict.py


注:本文中的UserDict.DictMixin.items方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。