LintCode:有效数字

LintCode:有效数字

人生苦短,我用Python!

class Solution:
    # @param {string} s the string that represents a number
    # @return {boolean} whether the string is a valid number
    def isNumber(self, s):
        # Write your code here
        num = None
        try:
            num = eval(s)
        except:
            pass
        if num != None:
            return True
        return False

你可能感兴趣的:(LintCode:有效数字)