• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python unicodedata.numeric函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中unicodedata.numeric函数的典型用法代码示例。如果您正苦于以下问题:Python numeric函数的具体用法?Python numeric怎么用?Python numeric使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: isNumber

    def isNumber(self, s):
        """
        :type s: str
        :rtype: bool
        """
      

        # s = str(s.strip())
        # if float(s):
        #     return True
        # else:
        #     return s.isdigit()
                
        try:
            float(s)
            return True
        except ValueError:
            pass
     
        try:
            import unicodedata
            unicodedata.numeric(s)
            return True
        except (TypeError, ValueError):
            pass
     
        return False
开发者ID:umasslowellmj,项目名称:leetcode.com,代码行数:27,代码来源:valid-number.py


示例2: convert_proj_total

def convert_proj_total(total):
	if len(total)==2:
		if unicodedata.numeric(total[1])==0.5:
			total=float(total[0])+unicodedata.numeric(total[1])
		else:
			total=float(total)
	elif len(total)==3:
		total=float(total[0:2])+unicodedata.numeric(total[2])
	elif len(total)==1:
		total=float(total)
	return total
开发者ID:emschorsch,项目名称:fanduel,代码行数:11,代码来源:general_utils.py


示例3: is_number

 def is_number(s):
     try:
         s = float(s)
         if math.isnan(s):
             return False
         return True
     except ValueError:
         try:
             unicodedata.numeric(s)
             return True
         except (TypeError, ValueError):
             return False
开发者ID:jiayanliu,项目名称:MachineLearning,代码行数:12,代码来源:NNUtil.py


示例4: is_number

def is_number(s):
    try:
        float(s)
        return True
    except ValueError:
        pass
    try:
        unicodedata.numeric(s)
        return True
    except (TypeError, ValueError):
        pass
    return False
开发者ID:DominikSchlecht,项目名称:Mobile-Security-Framework-MobSF,代码行数:12,代码来源:utils.py


示例5: is_number

    def is_number(s):
        try:
            float(s)
            return True
        except (ValueError, TypeError):
            pass

        try:
            import unicodedata
            unicodedata.numeric(s)
            return True
        except (TypeError, ValueError):
            pass
开发者ID:optimizely,项目名称:tcollector,代码行数:13,代码来源:samza_metric_reporter.py


示例6: is_number

    def is_number(self, s):
        try:
            float(s)
            return True
        except ValueError:
            return False

        try:
            import unicodedata
            unicodedata.numeric(s)
            return True
        except (TypeError, ValueError):
            return False
开发者ID:arteria-project,项目名称:arteria-lib,代码行数:13,代码来源:rest_tests.py


示例7: is_number

 def is_number(self, s):
     '''returns true if string is a number'''
     try:
         float(s)
         return True
     except ValueError:
         pass
     try:
         import unicodedata
         unicodedata.numeric(s)
         return True
     except (TypeError, ValueError):
         pass
     return False
开发者ID:urakozz,项目名称:python-solr-monitoring,代码行数:14,代码来源:data_jstats.py


示例8: is_number

def is_number(s):
    try:
        float(s)
        return True
    except:
        pass

    try:
        import unicodedata
        unicodedata.numeric(s)
        return True
    except:
        pass
    return False
开发者ID:sg3510,项目名称:IDAPI,代码行数:14,代码来源:IDAPICoursework04.py


示例9: isDigit

 def isDigit(self,s):
     s=s.replace(",","")
     try:
         float(s)
         return True
     except ValueError:
         pass
     try:
         import unicodedata
         unicodedata.numeric(s)
         return True
     except (TypeError, ValueError):
         pass
     return False
开发者ID:hejy12,项目名称:TestNLP,代码行数:14,代码来源:CommentClassify.py


示例10: test_parse_rand_utf8

    def test_parse_rand_utf8(self):
        h2o.beta_features = True
        SYNDATASETS_DIR = h2o.make_syn_dir()
        tryList = [
            (1000, 1, 'cA', 120),
            (1000, 1, 'cG', 120),
            (1000, 1, 'cH', 120),
            ]

        print "What about messages to log (INFO) about unmatched quotes (before eol)"
        # got this ..trying to avoid for now
        # Exception: rjson error in parse: Argument 'source_key' error: Parser setup appears to be broken, got AUTO

        for (rowCount, colCount, hex_key, timeoutSecs) in tryList:
            SEEDPERFILE = random.randint(0, sys.maxint)
            csvFilename = 'syn_' + str(SEEDPERFILE) + "_" + str(rowCount) + 'x' + str(colCount) + '.csv'
            csvPathname = SYNDATASETS_DIR + '/' + csvFilename

            print "\nCreating random", csvPathname
            write_syn_dataset(csvPathname, rowCount, colCount, SEEDPERFILE)
            parseResult = h2i.import_parse(path=csvPathname, schema='put', header=0,
                hex_key=hex_key, timeoutSecs=timeoutSecs, doSummary=False)
            print "Parse result['destination_key']:", parseResult['destination_key']
            inspect = h2o_cmd.runInspect(None, parseResult['destination_key'], timeoutSecs=60)
        
            print "inspect:", h2o.dump_json(inspect)
            numRows = inspect['numRows']
            self.assertEqual(numRows, rowCount, msg='Wrong numRows: %s %s' % (numRows, rowCount))
            numCols = inspect['numCols']
            self.assertEqual(numCols, colCount, msg='Wrong numCols: %s %s' % (numCols, colCount))

            for k in range(colCount):
                naCnt = inspect['cols'][k]['naCnt']
                self.assertEqual(0, naCnt, msg='col %s naCnt %d should be 0' % (k, naCnt))

                stype = inspect['cols'][k]['type']
                self.assertEqual("Enum", stype, msg='col %s type %s should be Enum' % (k, stype))

        #**************************
        # for background knowledge; (print info)
        import unicodedata
        u = unichr(233) + unichr(0x0bf2) + unichr(3972) + unichr(6000) + unichr(13231)

        for i, c in enumerate(u):
            print i, '%04x' % ord(c), unicodedata.category(c),
            print unicodedata.name(c)

        # Get numeric value of second character
        print unicodedata.numeric(u[1])
开发者ID:finid,项目名称:h2o,代码行数:49,代码来源:test_parse_rand_utf8.py


示例11: is_number

def is_number(a):
	try:
		float(a)
		return True
	except ValueError:
		pass

	try:
		import unicodedata
		unicodedata.numeric(a)
		return True
	except (TypeError, ValueError):
		pass

	return False
开发者ID:Andor-Z,项目名称:My-Learning-Note,代码行数:15,代码来源:check_is_number.py


示例12: is_integer

def is_integer(s):
    try:
        int(s)
        return True
    except ValueError:
        pass
 
    try:
        from unicodedata import numeric
        numeric(s)
        return True
    except (TypeError, ValueError):
        pass
 
	return False
开发者ID:terman110,项目名称:FileRenamer,代码行数:15,代码来源:songRenamer.py


示例13: is_number

def is_number(string):
    s = string.replace(',','')
    try: 
        float(s)
        return True
    except ValueError:
        pass

    try: 
        import unicodedata
        unicodedata.numeric(s)
        return True
    except (TypeError, ValueError):
        pass

    return False
开发者ID:cl2892proj,项目名称:DEF_PROX,代码行数:16,代码来源:def_14a.py


示例14: getdetails

    def getdetails(self, text):
        chardetails = {}
        for character in text:
            chardetails[character] = {}
            chardetails[character]['Name'] = unicodedata.name(character)
            chardetails[character]['HTML Entity'] = str(ord(character))
            chardetails[character]['Code point'] = repr(character)
            try:
                chardetails[character]['Numeric Value'] = \
                        unicodedata.numeric(character)
            except:
                pass
            try:
                chardetails[character]['Decimal Value'] = \
                        unicodedata.decimal(character)
            except:
                pass
            try:
                chardetails[character]['Digit'] = unicodedata.digit(mychar)
            except:
                pass
            chardetails[character]['Alphabet'] = str(character.isalpha())
            chardetails[character]['Digit'] = str(character.isdigit())
            chardetails[character]['AlphaNumeric'] = str(character.isalnum())
            chardetails[character]['Canonical Decomposition'] = \
                    unicodedata.decomposition(character)

        chardetails['Characters'] = list(text)
        return chardetails
开发者ID:copyninja,项目名称:chardetails,代码行数:29,代码来源:core.py


示例15: fromRoman

def fromRoman(S):
    "Convert a roman numeral string to binary"
    if type(S) is Roman: return int(S) #in case it already IS Roman
    result=0
    # Start by converting to upper case for convenience
    us = S.strip().upper()
    try:
        s = unicode(us)
    except UnicodeEncodeError: # IronPython bug
        s = us
    #test for zero
    if s == '' or s == u'N' or s[:5] == u'NULLA':  # Latin for "nothing"
        return 0
# This simplified algorithm (V.Cole) will correctly convert any correctly formed
# Roman number. It will also convert lots of incorrectly formed numbers, and will
# accept any combination of ASCII 'MCDLXVI' and unicode Roman Numeral code points.
    held = 0    # this is the memory for the previous Roman digit value
    for c in s:    #this will get the value of a sequence of unicode Roman Numeral points
        try:        # may be a normal alphabetic character
            val = _Rom[c]  #pick the value out of the dict
        except KeyError: # may be a unicode character with a value
            try:
                val = int(unicodedata.numeric(c))  # retrieve the value from the unicode chart
            except:
                raise InvalidRomanNumeralError, 'incorrectly formatted Roman Numeral '+repr(S)

        if val > held:    # if there was a smaller value to the left, subtract it
            result -= held
        else:             # otherwise add it
            result += held
        held = val        # try this loop's letter value on the next loop
    result += held  #the last letter value is always added
    return result
开发者ID:jeffreywinn,项目名称:jabbapylib,代码行数:33,代码来源:romanclass.py


示例16: getQuantity

def getQuantity(s):
    try:
        number = float(s)
        return s
    except ValueError:
        pass

    try:
        import unicodedata
        number = unicodedata.numeric(s)
        return ' ' + str(vulgarFractions.get(s, ''))
    except (TypeError, ValueError):
        pass

    try:
        number = float(Fraction(s))
        return s
    except ValueError:
        pass

    if len(s) == 1:
        return ''

    tmp = ''
    for c in s:
        q = getQuantity(c)
        if not q:
            return ''
        else:
            tmp += q

    return tmp
开发者ID:kar288,项目名称:saltedlime,代码行数:32,代码来源:parse.py


示例17: _convert_small_value

    def _convert_small_value(self, value, unit):
        power = unicodedata.numeric(unit) if unit else 1

        value = value if value else '1'
        total = float(value) * power

        return total
开发者ID:odoku,项目名称:PyJPString,代码行数:7,代码来源:normalizers.py


示例18: is_numeric

    def is_numeric(s):
        try:
            float(s)
        except ValueError:
            pass
        else:
            return True

        try:
            unicodedata.numeric(s)
        except (TypeError, ValueError):
            pass
        else:
            return True

        return False
开发者ID:mike-hart,项目名称:responsys,代码行数:16,代码来源:types.py


示例19: is_float

def is_float(s):
	# test wheter a value is a float or not
	try:
		float(s)
		return True
	except ValueError:
		pass
	
	try:
		import unicodedata
		unicodedata.numeric(s)
		return True
	except (TypeError, ValueError):
		pass

	return False
开发者ID:mseln,项目名称:yolo-octo-wallhack,代码行数:16,代码来源:algorithms.py


示例20: is_number

def is_number(s):
    """Check if it is a number string.
    """
    try:
        float(s)
        return True
    except ValueError:
        pass

    try:
        import unicodedata
        unicodedata.numeric(s)
        return True
    except (TypeError, ValueError):
        pass
    return False
开发者ID:demorest,项目名称:PINT,代码行数:16,代码来源:utils.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ucd_3_2_0.category函数代码示例发布时间:2022-05-27
下一篇:
Python unicodedata.normalize函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap