Latest web development tutorials

Pythonのisdigitは()メソッド

Python文字列 Python文字列


説明

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

Python文字列 Python文字列