获取文本行中阿拉伯数字数的个数

    Keyword arguments:
    unit                    -- 文本行
    Return:
        nn                  -- 数字数
337752
def get_nn(unit):
    
    nn = 0
    match_re = re.findall(number, unit)
    if match_re:
        string = ''.join(match_re)
        nn = len(string)
    return int(nn)
670697
def to(self, unit):
        """"""
        from astropy.units import au
        return (self.au * au).to(unit)
1055141
def sizeof_fmt(num: float, suffix: str = 'B') -> str:
    
    for unit in ('', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi'):
        if abs(num) < 1024.0:
            return "%3.1f%s%s" % (num, unit, suffix)
        num /= 1024.0
    return "%.1f%s%s" % (num, 'Yi', suffix)
1368961
def first_unit(unit_raw, init_dict, fake_title):
    
    init_corpus = {}
    for i in range(0, 3):
        try:
            c = CDM(unit_raw[init_dict[i][0]])
            init_corpus[init_dict[i][0]] = c.get_alpha([i for i in cut_for_search(fake_title)]) + c.SN
        except IndexError:
            break
    init_corpus = sorted(init_corpus.items(), key=lambda item: item[1], reverse=True)

    log('debug', '\n初始化语料库完成，初始语料为：【{}】\n'.format(unit_raw[init_corpus[0][0]]))
    return init_corpus
472545
def altimeter(alt: Number, unit: str = 'inHg') -> str:
    
    ret = 'Altimeter '
    if not alt:
        ret += 'unknown'
    elif unit == 'inHg':
        ret += core.spoken_number(alt.repr[:2]) + ' point ' + core.spoken_number(alt.repr[2:])
    elif unit == 'hPa':
        ret += core.spoken_number(alt.repr)
    return ret
1142094
def _numbers_units(N):
    
    lst = range(1, N + 1)
    return "".join(list(map(lambda i: str(i % 10), lst)))
1297972
def to(self, unit):
        
        u = Unit("0cm")
        u.value = self.value/self.per_inch[self.unit]*self.per_inch[unit]
        u.unit = unit
        return u
842028
def get_scn(unit):
    
    scn = 0
    list = cut_for_search(unit)
    for x in list:
        for y in chinese_character:
            if x == y:
                scn += len(y)
    return int(scn)
679629
def get_value_unit(value, unit, prefix):
    
    prefixes = ('', 'K', 'M', 'G', 'T')

    if len(unit):
        if unit[:1] in prefixes:
            valprefix = unit[0] 
            unit = unit[1:]
        else:
            valprefix = ''
    else:
        valprefix = ''
    
    while valprefix != prefix:
        uidx = prefixes.index(valprefix)

        if uidx > prefixes.index(prefix):
            value *= 1024
            valprefix = prefixes[uidx-1]
        else:
            if value < 10240:
                return value, '{0}{1}'.format(valprefix, unit)
            value = int(round(value/1024.0))
            valprefix = prefixes[uidx+1]
    return value, '{0}{1}'.format(valprefix, unit)
944301
def get_units(**kwargs):
    
    units_list = db.DBSession.query(Unit).all()
    units = []
    for unit in units_list:
        new_unit = JSONObject(unit)
        units.append(new_unit)

    return units
934715
def get_dimension_by_unit_measure_or_abbreviation(measure_or_unit_abbreviation,**kwargs):
    

    unit_abbreviation, factor = _parse_unit(measure_or_unit_abbreviation)

    units = db.DBSession.query(Unit).filter(Unit.abbreviation==unit_abbreviation).all()

    if len(units) == 0:
        raise HydraError('Unit %s not found.'%(unit_abbreviation))
    elif len(units) > 1:
        raise HydraError('Unit %s has multiple dimensions not found.'%(unit_abbreviation))
    else:
        dimension = db.DBSession.query(Dimension).filter(Dimension.id==units[0].dimension_id).one()
        return str(dimension.name)
1145061
def strip_units_from_lines(lines):
    
    for line in lines:
        for unit in ALL_UNITS:
            if line.endswith(" %s" % unit):
                line = line[:-1-len(unit)]
        yield line
1202566
def __name_unit_regex(word):
        
        value = ""
        unit = ""
        r = re.findall(re_name_unit, word)
        try:
            value = r[0][0]
        except IndexError as e:
            logger_noaa_lpd.warn("name_unit_regex: IndexError: value: {}, {}, {}".format(word, r, e))
        try:
            unit = r[0][1]
            # Replace unit with correct synonym.
            if unit.lower() in UNITS:
                unit = UNITS[unit]
        except IndexError as e:
            logger_noaa_lpd.warn("name_unit_regex: IndexError: unit: {}, {}, {}".format(word, r, e))
        if value:
            try:
                value = float(value)
            except ValueError as e:
                logger_noaa_lpd.warn("name_unit_regex: ValueError: val: {}, {}".format(value, e))
        return value, unit
213085
def get_value(self, i, indeps=None):
        
        if self.value is None:
            return None

        if i is None:
            return np.median(self.value)

        if indeps is None:
            indeps_all_calls = list(set(np.concatenate([common.tolist(call.i.get_value(unit=self.axes.i.unit)) for call in self.axes.calls])))
            indeps = np.linspace(np.nanmin(indeps_all_calls),
                                 np.nanmax(indeps_all_calls),
                                 len(self.value))

        if len(indeps) != len(self.value):
            raise ValueError("indeps and value must have same length")

        return np.interp(i, indeps, self.value)
1233195
def from_wei(number: int, unit: str) -> Union[int, decimal.Decimal]:
    
    if unit.lower() not in units:
        raise ValueError(
            "Unknown unit.  Must be one of {0}".format("/".join(units.keys()))
        )

    if number == 0:
        return 0

    if number < MIN_WEI or number > MAX_WEI:
        raise ValueError("value must be between 1 and 2**256 - 1")

    unit_value = units[unit.lower()]

    with localcontext() as ctx:
        ctx.prec = 999
        d_number = decimal.Decimal(value=number, context=ctx)
        result_value = d_number / unit_value

    return result_value
1253422
def str_to_num(self, arg):
        

        if len(arg) == 1:
            ten = '10'
        else:
            ten = ''
        switcher = {
            '一': '1',
            '二': '2',
            '三': '3',
            '四': '4',
            '五': '5',
            '六': '6',
            '七': '7',
            '八': '8',
            '九': '9',
            '十': ten,
            '〇': '0',
            '○': '0',
        }
        test = ''
        for i in arg:
            test = test + switcher.get(i, None)
        return int(test)
25099
def unit(self, parameter):
        ""
        parameter = self._get_parameter_name(parameter).lower()
        return self._parameters[parameter]['Unit']