How do I check if a string is a number (float) in Python?

http://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float-in-python

 

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

 

相关文章:

  • 2021-06-02
  • 2021-12-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-10
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-06
相关资源
相似解决方案