Pythonのisdigitは()メソッド
説明
Pythonのisdigitは()数字のみで構成される文字列を検出する方法があります。
文法
isdigitは()メソッドの構文:
str.isdigit()
パラメータ
- なし。
戻り値
文字列は真そうでなければFalse数値のみを返しますが含まれている場合。
例
次の例では、isdigitは()メソッドの例を示します。
#!/usr/bin/python str = "123456"; # Only digit in this string print str.isdigit(); str = "this is string example....wow!!!"; print str.isdigit();
次のように上記の出力結果の例は次のとおりです。
True False