LoginSignup
0
0

More than 1 year has passed since last update.

小数や符号付きの文字列が数値か判定

Posted at

小数や符号付きの文字列が数値か判定するには、例外処理を用いるのが一般的。

text = -1.234
try:
    float(text)
    print("Numeric!")
except ValueError:
    print("Not Numeric!")
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0