判断一个变量是否数字(整数、浮点数)
>>> isinstance(1, (int, long, float))
True
>>> isinstance('a', (int, long, float))
False
判断一个字符串的内容是否表示数字(整数、浮点数)
>>> foo = '123.456'
>>> foo.replace('.', '', 1).isdigit()
True
>>> bar = '12.34.56'
>>> bar.replace('.', '', 1).isdigit()
False