當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。