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


Python str.lower方法代码示例

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


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

示例1: english_lower

# 需要导入模块: from builtins import str [as 别名]
# 或者: from builtins.str import lower [as 别名]
def english_lower(s):
    """ Apply English case rules to convert ASCII strings to all lower case.

    This is an internal utility function to replace calls to str.lower() such
    that we can avoid changing behavior with changing locales. In particular,
    Turkish has distinct dotted and dotless variants of the Latin letter "I" in
    both lowercase and uppercase. Thus, "I".lower() != "i" in a "tr" locale.

    Parameters
    ----------
    s : str

    Returns
    -------
    lowered : str

    Examples
    --------
    >>> from numpy.core.numerictypes import english_lower
    >>> english_lower('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_')
    'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789_'
    >>> english_lower('')
    ''
    """
    lowered = s.translate(LOWER_TABLE)
    return lowered 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:28,代码来源:numerictypes.py

示例2: issubdtype

# 需要导入模块: from builtins import str [as 别名]
# 或者: from builtins.str import lower [as 别名]
def issubdtype(arg1, arg2):
    """
    Returns True if first argument is a typecode lower/equal in type hierarchy.

    Parameters
    ----------
    arg1, arg2 : dtype_like
        dtype or string representing a typecode.

    Returns
    -------
    out : bool

    See Also
    --------
    issubsctype, issubclass_
    numpy.core.numerictypes : Overview of numpy type hierarchy.

    Examples
    --------
    >>> np.issubdtype('S1', str)
    True
    >>> np.issubdtype(np.float64, np.float32)
    False

    """
    if issubclass_(arg2, generic):
        return issubclass(dtype(arg1).type, arg2)
    mro = dtype(arg2).type.mro()
    if len(mro) > 1:
        val = mro[1]
    else:
        val = mro[0]
    return issubclass(dtype(arg1).type, val)


# This dictionary allows look up based on any alias for an array data-type 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:39,代码来源:numerictypes.py

示例3: lc_get_close_matches

# 需要导入模块: from builtins import str [as 别名]
# 或者: from builtins.str import lower [as 别名]
def lc_get_close_matches(lbl, possibilities, num_matches=3, cutoff=0.6):
    '''Return list of closest matches to lbl from possibilities (case-insensitive).'''

    # Strip any non-strings so str.lower() doesn't crash.
    possibilities = [p for p in possibilities if isinstance(p, basestring)]

    if USING_PYTHON2:
        lc_lbl = str.lower(unicode(lbl))
        lc_possibilities = [str.lower(unicode(p)) for p in possibilities]
    else:
        lc_lbl = str.lower(lbl)
        lc_possibilities = [str.lower(p) for p in possibilities]
    lc_matches = get_close_matches(lc_lbl, lc_possibilities, num_matches, cutoff)
    return [possibilities[lc_possibilities.index(m)] for m in lc_matches] 
开发者ID:xesscorp,项目名称:KiField,代码行数:16,代码来源:kifield.py

示例4: find_header_column

# 需要导入模块: from builtins import str [as 别名]
# 或者: from builtins.str import lower [as 别名]
def find_header_column(header, lbl):
    '''Find the field header column containing the closest match to the given label.'''

    header_labels = [cell.value for cell in header]
    lbl_match = lc_get_close_matches(lbl, header_labels, 1, 0.0)[0]
    for cell in header:
        if str(cell.value).lower() == lbl_match.lower():
            logger.log(DEBUG_OBSESSIVE,
                       'Found {} on header column {}.'.format(lbl,
                                                              cell.column))
            return cell.column, lbl_match
    raise FindLabelError('{} not found in spreadsheet'.format(lbl)) 
开发者ID:xesscorp,项目名称:KiField,代码行数:14,代码来源:kifield.py

示例5: computation_name_to_method

# 需要导入模块: from builtins import str [as 别名]
# 或者: from builtins.str import lower [as 别名]
def computation_name_to_method(name):
        """
        generate the name of the method in manager for a given ComputationStep name

        taken from https://stackoverflow.com/questions/1175208/elegant-python-function-to-convert-camelcase-to-snake-case

        >>> OasisManager.computation_name_to_method('ExposurePreAnalysis')
        'generate_exposure_pre_analysis'
        >>> OasisManager.computation_name_to_method('EODFile')
        'generate_eod_file'
        >>> OasisManager.computation_name_to_method('Model1Data')
        'generate_model1_data'
        """
        return 'generate_' + re.sub('((?<=[a-z0-9])[A-Z]|(?!^)[A-Z](?=[a-z]))', r'_\1', name).lower() 
开发者ID:OasisLMF,项目名称:OasisLMF,代码行数:16,代码来源:manager.py

示例6: extract_part_fields

# 需要导入模块: from builtins import str [as 别名]
# 或者: from builtins.str import lower [as 别名]
def extract_part_fields(filenames, inc_field_names=None, exc_field_names=None, recurse=False):
    '''Return a dictionary of part fields extracted from a spreadsheet, part library, DCM, or schematic.'''

    logger.log(DEBUG_OVERVIEW,
               'Extracting fields +{}, -{} from files {}.'.format(inc_field_names, exc_field_names,
                                                            filenames))

    # Table of extraction functions for each file type.
    extraction_functions = {
        '.xlsx': extract_part_fields_from_xlsx,
        '.tsv': extract_part_fields_from_csv,
        '.csv': extract_part_fields_from_csv,
        '.sch': extract_part_fields_from_sch,
        '.lib': extract_part_fields_from_lib,
        '.dcm': extract_part_fields_from_dcm,
    }

    part_fields_dict = {}  # Start with empty part field dictionary.

    # If extracting from only a single file, make a one-entry list.
    if type(filenames) == str:
        filenames = [filenames]

    # Extract the fields from the parts in each file.
    for f in filenames:
        try:
            logger.log(DEBUG_DETAILED, 'Extracting fields from {}.'.format(f))

            # Call the extraction function based on the file extension.
            f_extension = os.path.splitext(f)[1].lower()
            f_part_fields_dict = extraction_functions[f_extension](f, inc_field_names, exc_field_names, recurse)

            # Add the extracted fields to the total part dictionary.
            part_fields_dict = combine_part_field_dicts(f_part_fields_dict, part_fields_dict)

        except IOError:
            logger.warn('File not found: {}.'.format(f))

        except KeyError:
            logger.warn('Unknown file type for field extraction: {}.'.format(
                f))


    if logger.isEnabledFor(DEBUG_DETAILED):
        print('Total Extracted Part Fields:')
        pprint(part_fields_dict)

    if part_fields_dict is None or len(part_fields_dict) == 0:
        logger.warn("No part fields were extracted from these files: {}\n  * Did you provide a list of files?\n  * Do these files exist?\n  * Did you annotate your components in the schematic?".format(', '.join(filenames)))
        return

    return part_fields_dict 
开发者ID:xesscorp,项目名称:KiField,代码行数:54,代码来源:kifield.py

示例7: insert_part_fields

# 需要导入模块: from builtins import str [as 别名]
# 或者: from builtins.str import lower [as 别名]
def insert_part_fields(part_fields_dict, filenames, recurse, group_components, backup):
    '''Insert part fields from a dictionary into a spreadsheet, part library, or schematic.'''

    # No files backed-up yet, so clear list of file names.
    global backedup_files
    backedup_files = []

    logger.log(DEBUG_OVERVIEW,
               'Inserting extracted fields into files {}.'.format(filenames))

    # Table of insertion functions for each file type.
    insertion_functions = {
        '.xlsx': insert_part_fields_into_xlsx,
        '.tsv': insert_part_fields_into_csv,
        '.csv': insert_part_fields_into_csv,
        '.sch': insert_part_fields_into_sch,
        '.lib': insert_part_fields_into_lib,
        '.dcm': insert_part_fields_into_dcm,
    }

    if part_fields_dict is None or len(part_fields_dict) == 0:
        logger.warn("There are no part field values to insert!")
        return

    # If inserting into a single file, make a one-entry list.
    if type(filenames) == str:
        filenames = [filenames]

    # Insert the part fields into each file.
    for f in filenames:
        try:
            logger.log(DEBUG_DETAILED, 'Inserting fields into {}.'.format(f))

            # Call the insertion function based on the file extension.
            f_extension = os.path.splitext(f)[1].lower()
            insertion_functions[f_extension](part_fields_dict, f, recurse, group_components, backup)

        except IOError:
            logger.warn('Unable to write to file: {}.'.format(f))

        except KeyError:
            logger.warn('Unknown file type for field insertion: {}'.format(f)) 
开发者ID:xesscorp,项目名称:KiField,代码行数:44,代码来源:kifield.py


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