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


Python string.capwords方法代码示例

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


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

示例1: _remove_heist

# 需要导入模块: import string [as 别名]
# 或者: from string import capwords [as 别名]
def _remove_heist(self, ctx, *, target: str):
        """Remove a target from the heist list"""
        author = ctx.message.author
        guild = ctx.guild
        targets = await self.thief.get_guild_targets(guild)
        if string.capwords(target) in targets:
            await ctx.send("Are you sure you want to remove {} from the list of "
                               "targets?".format(string.capwords(target)))
            response = await self.bot.wait_for('MESSAGE', timeout=15, check=lambda x: x.author == author)
            if response is None:
                msg = "Canceling removal. You took too long."
            elif response.content.title() == "Yes":
                targets.pop(string.capwords(target))
                await self.thief.save_targets(guild, targets)
                msg = "{} was removed from the list of targets.".format(string.capwords(target))
            else:
                msg = "Canceling target removal."
        else:
            msg = "That target does not exist."
        await ctx.send(msg) 
开发者ID:Malarne,项目名称:discord_cogs,代码行数:22,代码来源:heist.py

示例2: _extractNVMLErrorsAsClasses

# 需要导入模块: import string [as 别名]
# 或者: from string import capwords [as 别名]
def _extractNVMLErrorsAsClasses():
    '''
    Generates a hierarchy of classes on top of NVMLError class.

    Each NVML Error gets a new NVMLError subclass. This way try,except blocks can filter appropriate
    exceptions more easily.

    NVMLError is a parent class. Each NVML_ERROR_* gets it's own subclass.
    e.g. NVML_ERROR_ALREADY_INITIALIZED will be turned into NVMLError_AlreadyInitialized
    '''
    this_module = sys.modules[__name__]
    nvmlErrorsNames = filter(lambda x: x.startswith("NVML_ERROR_"), dir(this_module))
    for err_name in nvmlErrorsNames:
        # e.g. Turn NVML_ERROR_ALREADY_INITIALIZED into NVMLError_AlreadyInitialized
        class_name = "NVMLError_" + string.capwords(err_name.replace("NVML_ERROR_", ""), "_").replace("_", "")
        err_val = getattr(this_module, err_name)
        def gen_new(val):
            def new(typ):
                obj = NVMLError.__new__(typ, val)
                return obj
            return new
        new_error_class = type(class_name, (NVMLError,), {'__new__': gen_new(err_val)})
        new_error_class.__module__ = __name__
        setattr(this_module, class_name, new_error_class)
        NVMLError._valClassMapping[err_val] = new_error_class 
开发者ID:opteroncx,项目名称:MoePhoto,代码行数:27,代码来源:pynvml.py

示例3: _get_es_results

# 需要导入模块: import string [as 别名]
# 或者: from string import capwords [as 别名]
def _get_es_results(query: str, category: str, keyphrase: str, strict: bool) -> Response:
    skill_search = es_search
    if category:
        skill_search = skill_search.query('match',
                                          category=string.capwords(category)
                                          .replace(' And ', ' & ')
                                          .replace('Movies & Tv', 'Movies & TV'))
    if keyphrase:
        skill_search = skill_search.query('match', keyphrases=keyphrase)
    if query:
        operator = 'and' if strict else 'or'
        skill_search = skill_search.query('multi_match',
                                          query=query,
                                          fields=['name', 'description', 'usages', 'keyphrases'],
                                          minimum_should_match='50%',
                                          operator=operator) \
            .highlight('description', order='score', pre_tags=['*'], post_tags=['*']) \
            .highlight('title', order='score', pre_tags=['*'], post_tags=['*']) \
            .highlight('usages', order='score', pre_tags=['*'], post_tags=['*'])

    return skill_search.execute() 
开发者ID:allenai,项目名称:alexafsm,代码行数:23,代码来源:clients.py

示例4: test_names

# 需要导入模块: import string [as 别名]
# 或者: from string import capwords [as 别名]
def test_names(self):
        """Ensure extractor classes are named CategorySubcategoryExtractor"""
        def capitalize(c):
            if "-" in c:
                return string.capwords(c.replace("-", " ")).replace(" ", "")
            return c.capitalize()

        for extr in extractor.extractors():
            if extr.category not in ("", "oauth"):
                expected = "{}{}Extractor".format(
                    capitalize(extr.category),
                    capitalize(extr.subcategory),
                )
                if expected[0].isdigit():
                    expected = "_" + expected
                self.assertEqual(expected, extr.__name__) 
开发者ID:mikf,项目名称:gallery-dl,代码行数:18,代码来源:test_extractor.py

示例5: get_embeddings

# 需要导入模块: import string [as 别名]
# 或者: from string import capwords [as 别名]
def get_embeddings(self, word):
        word_list = [word, word.upper(), word.lower(), word.title(), string.capwords(word, '_')]

        for w in word_list:
            try:
                return self.model[w]
            except KeyError:
                # print('Can not get embedding for ', w)
                continue
        return None 
开发者ID:hugochan,项目名称:BAMnet,代码行数:12,代码来源:generic_utils.py

示例6: name2class

# 需要导入模块: import string [as 别名]
# 或者: from string import capwords [as 别名]
def name2class(self, name):
        return getattr(text_classification, string.capwords(name, '_').replace('_', '')) 
开发者ID:tofunlp,项目名称:lineflow,代码行数:4,代码来源:test_text_classification.py

示例7: shortf

# 需要导入模块: import string [as 别名]
# 或者: from string import capwords [as 别名]
def shortf(acronym):
	n = int(raw_input("Enter the number of inputs"))
	for acronym in range(n):
		acronym1 = string.capwords(acronym)
		list(acronym1)
		
	print output 
开发者ID:sai29,项目名称:Python-John-Zelle-book,代码行数:9,代码来源:10.py

示例8: main

# 需要导入模块: import string [as 别名]
# 或者: from string import capwords [as 别名]
def main():
	n = int(raw_input("Enter the number of inputs"))
	output = ""
	for acronym in range(n):
		acronym = raw_input("Enter the input: ")
		acronym1 = string.capwords(acronym)
		
		list(acronym1)
		
	print output 
开发者ID:sai29,项目名称:Python-John-Zelle-book,代码行数:12,代码来源:5.py

示例9: convert_to_cpp_identifier

# 需要导入模块: import string [as 别名]
# 或者: from string import capwords [as 别名]
def convert_to_cpp_identifier(s, sep):
    return string.capwords(s, sep).replace(sep, "") 
开发者ID:mozilla,项目名称:probe-scraper,代码行数:4,代码来源:parse_events.py

示例10: format_command_part

# 需要导入模块: import string [as 别名]
# 或者: from string import capwords [as 别名]
def format_command_part(name):
    name = re.sub("[^a-zA-Z]", "-", name)
    name = string.capwords(name, "-")
    name = name.replace("-", "")
    return name 
开发者ID:sosy-lab,项目名称:benchexec,代码行数:7,代码来源:statistics-tex.py

示例11: test_capwords

# 需要导入模块: import string [as 别名]
# 或者: from string import capwords [as 别名]
def test_capwords(self):
        self.assertEqual(string.capwords('abc def ghi'), 'Abc Def Ghi')
        self.assertEqual(string.capwords('abc\tdef\nghi'), 'Abc Def Ghi')
        self.assertEqual(string.capwords('abc\t   def  \nghi'), 'Abc Def Ghi')
        self.assertEqual(string.capwords('ABC DEF GHI'), 'Abc Def Ghi')
        self.assertEqual(string.capwords('ABC-DEF-GHI', '-'), 'Abc-Def-Ghi')
        self.assertEqual(string.capwords('ABC-def DEF-ghi GHI'), 'Abc-def Def-ghi Ghi')
        self.assertEqual(string.capwords('   aBc  DeF   '), 'Abc Def')
        self.assertEqual(string.capwords('\taBc\tDeF\t'), 'Abc Def')
        self.assertEqual(string.capwords('\taBc\tDeF\t', '\t'), '\tAbc\tDef\t') 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:test_string.py

示例12: title_filter

# 需要导入模块: import string [as 别名]
# 或者: from string import capwords [as 别名]
def title_filter(self, result):
        title = source_utils.clean_tags(result.title.strip())
        title = source_utils.remove_sep(title, self._title)
        title = normalize(title).replace('+', ' ')
        return capwords(title) 
开发者ID:a4k-openproject,项目名称:a4kScrapers,代码行数:7,代码来源:scrapers.py

示例13: to_capital_camel_case

# 需要导入模块: import string [as 别名]
# 或者: from string import capwords [as 别名]
def to_capital_camel_case(s):
    """Converts a string to camel case.

    Parameters
    ----------
    s : str
        Input string.

    Returns
    -------
    str
        Input string `s` converted to camel case.

    """
    return s[0].capitalize() + string.capwords(s, sep='_').replace('_', '')[1:] if s else s 
开发者ID:DIVA-DIA,项目名称:DeepDIVA,代码行数:17,代码来源:misc.py

示例14: __name__

# 需要导入模块: import string [as 别名]
# 或者: from string import capwords [as 别名]
def __name__(self):
        feat_name = []
        for m1 in self.aggregation_mode_prev:
            for m in self.aggregation_mode:
                n = "WordNet_%s_Similarity_%s_%s"%(
                    string.capwords(self.metric), string.capwords(m1), string.capwords(m))
                feat_name.append(n)
        return feat_name 
开发者ID:ChenglongChen,项目名称:kaggle-HomeDepot,代码行数:10,代码来源:feature_wordnet_similarity.py

示例15: __name__

# 需要导入模块: import string [as 别名]
# 或者: from string import capwords [as 别名]
def __name__(self):
        if isinstance(self.aggregation_mode, str):
            feat_name = "FirstIntersectPosition_%s_%s"%(
                self.ngram_str, string.capwords(self.aggregation_mode))
        elif isinstance(self.aggregation_mode, list):
            feat_name = ["FirstIntersectPosition_%s_%s"%(
                self.ngram_str, string.capwords(m)) for m in self.aggregation_mode]
        return feat_name 
开发者ID:ChenglongChen,项目名称:kaggle-HomeDepot,代码行数:10,代码来源:feature_first_last_ngram.py


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