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


Python locale.atoi方法代码示例

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


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

示例1: numberFromString

# 需要导入模块: import locale [as 别名]
# 或者: from locale import atoi [as 别名]
def numberFromString(self, string):
        # Uses the current system locale, irrespective of language choice.
        # Returns None if the string is not parsable, otherwise an integer or float.
        if platform=='darwin':
            return self.float_formatter.numberFromString_(string)
        else:
            try:
                return locale.atoi(string)
            except:
                try:
                    return locale.atof(string)
                except:
                    return None

    # Returns list of preferred language codes in RFC4646 format i.e. "lang[-script][-region]"
    # Where lang is a lowercase 2 alpha ISO 639-1 or 3 alpha ISO 639-2 code,
    # script is a capitalized 4 alpha ISO 15924 code and region is an uppercase 2 alpha ISO 3166 code 
开发者ID:EDCD,项目名称:EDMarketConnector,代码行数:19,代码来源:l10n.py

示例2: get_values

# 需要导入模块: import locale [as 别名]
# 或者: from locale import atoi [as 别名]
def get_values(soup, row_class):
    """get values from a specific summary row based on the row class"""
    locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')  # for number parsing

    values = []

    cells = soup.find('tr', {'class': row_class}).find_all('td')

    for elem in cells[1:]:
        # if there's a child span with class "macro-value", use its value
        # otherwise use the cell text
        span = elem.find('span', {'class': 'macro-value'})
        if span:
            value = span.text
        else:
            value = elem.text

        if value.strip() != '':
            values.append(locale.atoi(value))

    return values 
开发者ID:TotallyNotRobots,项目名称:CloudBot,代码行数:23,代码来源:myfitnesspal.py

示例3: is_number

# 需要导入模块: import locale [as 别名]
# 或者: from locale import atoi [as 别名]
def is_number(s):
    try:
        locale.atof(s)
        return True
    except ValueError:
        pass
    # put string like '3\/32' into numbers
    try:
        special_str = '\/'
        pos = s.find(special_str)
        if pos > 0:
            locale.atoi(s[:pos])
            locale.atoi(s[pos+len(special_str):])
            return True
    except ValueError:
        pass
    return False 
开发者ID:RemiLeblond,项目名称:SeaRNN-open,代码行数:19,代码来源:conll.py

示例4: get_method

# 需要导入模块: import locale [as 别名]
# 或者: from locale import atoi [as 别名]
def get_method(self):
        def custom_int(data):
            data = locale.atoi(data)
            return int(data)

        return custom_int 
开发者ID:invanalabs,项目名称:invana-bot,代码行数:8,代码来源:single.py

示例5: cast

# 需要导入模块: import locale [as 别名]
# 或者: from locale import atoi [as 别名]
def cast(self, value):
        if self.regex.match(value):
            return int(value)

        try:
            value = float(value)
        except:
            return locale.atoi(value)

        if value.is_integer():
            return int(value)
        else:
            raise ValueError('Invalid integer: %s' % value) 
开发者ID:MacroConnections,项目名称:DIVE-backend,代码行数:15,代码来源:type_classes.py

示例6: cast

# 需要导入模块: import locale [as 别名]
# 或者: from locale import atoi [as 别名]
def cast(self, value):
        if value in ('', None):
            return None
        try:
            value = float(value)
        except:
            return locale.atoi(value)

        if value.is_integer():
            return int(value)
        else:
            raise ValueError('Invalid integer: %s' % value) 
开发者ID:MacroConnections,项目名称:DIVE-backend,代码行数:14,代码来源:types.py

示例7: _test_atoi

# 需要导入模块: import locale [as 别名]
# 或者: from locale import atoi [as 别名]
def _test_atoi(self, value, out):
        self.assertEqual(locale.atoi(value), out) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:4,代码来源:test_locale.py

示例8: convertNumber

# 需要导入模块: import locale [as 别名]
# 或者: from locale import atoi [as 别名]
def convertNumber(data):
    locale.setlocale( locale.LC_ALL, 'en_US.UTF-8')
    num = locale.atoi(data)
    if is_number(num):
        return num
    else:
        msg = '[*] %s is not a number' % (data)
        logging.error(msg)
        return 0 
开发者ID:maltelligence,项目名称:maltelligence,代码行数:11,代码来源:utility.py

示例9: cast

# 需要导入模块: import locale [as 别名]
# 或者: from locale import atoi [as 别名]
def cast(self, value):
        if value in ('', None):
            return None

        try:
            value = float(value)
        except:
            return locale.atoi(value)

        if value.is_integer():
            return int(value)
        else:
            raise ValueError('Invalid integer: %s' % value) 
开发者ID:bailaohe,项目名称:parade,代码行数:15,代码来源:stdtypes.py

示例10: CreateFromString

# 需要导入模块: import locale [as 别名]
# 或者: from locale import atoi [as 别名]
def CreateFromString(cls, text, consider_locale=True):
        """
        Create a FractionValue from a string.

        :param str text:
            The text with a fraction-value, that is, three integers separated by space and slash
            respectively.
            <value> <value>/<value>

        :param bool consider_locale:
            Consider the locale on converting string to float

        :rtype: FractionValue
        :returns:
            The fraction value

        :raises ValueError:
            If the text is not convertible to a FractionValue
        """
        text = str(text).strip()

        if consider_locale:
            string_to_float_callable = FloatFromString
        else:
            string_to_float_callable = float

        # First try to match only the fractional part.
        m = cls._FRACTION_PARTIAL_RE.match(text)
        if m is not None:
            number = None
        else:
            # If can't match a fraction try a mixed number
            m = cls._FRACTION_RE.match(text)
            if m is None:
                raise ValueError('Please enter a text in the form: "5 3/4"')
            number = m.group("float")

        if number is None:
            number = 0.0
        else:
            number = string_to_float_callable(number)

        if m.group("numerator") is not None and m.group("denominator") is not None:
            numerator = string_to_float_callable(m.group("numerator"))
            denominator = locale.atoi(m.group("denominator"))
            fraction = Fraction(numerator, denominator)
        else:
            fraction = Fraction(0.0, 1.0)

        return FractionValue(number, fraction) 
开发者ID:ESSS,项目名称:barril,代码行数:52,代码来源:_fraction_value.py

示例11: unpickleVars

# 需要导入模块: import locale [as 别名]
# 或者: from locale import atoi [as 别名]
def unpickleVars(pdb2pqrID):
    """ Converts instance pickle from PDB2PQR into a dictionary for APBS """
    apbsOptions = {}
    #pfile = open("/home/samir/public_html/pdb2pqr/tmp/%s-input.p" % pdb2pqrID, 'r')
    pfile = open("%s%s%s/%s-input.p" % (INSTALLDIR, TMPDIR, pdb2pqrID, pdb2pqrID), 'r')
    inputObj = pickle.load(pfile)
    pfile.close()
    myElec = inputObj.elecs[0]

    apbsOptions['pqrname'] = pdb2pqrID+'.pqr'
    apbsOptions['pdbID'] = inputObj.pqrname[:-4]
    
    if myElec.cgcent[0:3] == "mol":
        apbsOptions['coarseGridCenterMethod'] = "molecule"
        apbsOptions['coarseGridCenterMoleculeID'] = locale.atoi(myElec.cgcent[4:])
    else:
        apbsOptions['coarseGridCenterMethod'] = "coordinate"
        apbsOptions['coarseGridCenter'] = myElec.cgcent

    if myElec.fgcent[0:3] == "mol":
        apbsOptions['fineGridCenterMethod'] = "molecule"
        apbsOptions['fineGridCenterMoleculeID'] = locale.atoi(myElec.fgcent[4:])
    else:
        apbsOptions['fineGridCenterMethod'] = "coordinate"
        apbsOptions['fineGridCenter'] = myElec.fgcent

    if myElec.gcent[0:3] == "mol":
        apbsOptions['gridCenterMethod'] = "molecule"
        apbsOptions['gridCenterMoleculeID'] = locale.atoi(myElec.gcent[4:])
    else:
        apbsOptions['gridCenterMethod'] = "coordinate"
        apbsOptions['gridCenter'] = myElec.gcent


    if myElec.lpbe == 1:
        apbsOptions['solveType'] = 'linearized'
    elif myElec.npbe == 1:
        apbsOptions['solveType'] = 'nonlinearized'

    if len(myElec.ion) == 0:
        apbsOptions['mobileIonSpecies[0]'] = None
    else:
        apbsOptions['mobileIonSpecies[1]'] = myElec.ion

    if len(myElec.write) <= 1:
        apbsOptions['format'] = 'dx'
    else:
        apbsOptions['format'] = myElec.write[1]

    apbsOptions['calculationType'] = myElec.method
    apbsOptions['dime'] = myElec.dime
    apbsOptions['pdime'] = myElec.pdime
    apbsOptions['async'] = myElec.async 
开发者ID:MonZop,项目名称:BioBlender,代码行数:55,代码来源:apbs_cgi.py


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