日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

Python字符串| isdecimal()方法与示例

發布時間:2025/3/11 python 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Python字符串| isdecimal()方法与示例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

isdecimal() is an in-built method in Python, which is used to check whether a string contains only decimal characters or not.

isdecimal()是Python中的內置方法,用于檢查字符串是否僅包含十進制字符。

Note:

注意:

  • Decimal characters contain all digits from 0 to 9.

    十進制字符包含從0到9的所有數字。

  • String should be Unicode object - to define a string as Unicode object, we use u as prefix of the string value.

    字符串應為Unicode對象-要將字符串定義為Unicode對象,我們使用u作為字符串值的前綴。

Syntax:

句法:

String.isdecimal();

Parameter: None

參數:無

Return type:

返回類型:

  • true - If all characters of the string are decimal characters then method returns true.

    true-如果字符串的所有字符均為十進制字符,則method返回true 。

  • false - If any of the characters of the string is not a decimal character then method returns false.

    false-如果字符串中的任何字符都不為十進制字符,則方法返回false 。

Example/program:

示例/程序:

# str1 with only decimal characters str1 = u"362436" print str1.isdecimal ()# str2 with alphabets and decimal characters str2 = u"Hello36" print str2.isdecimal ()# str3 with alphabets and special characters str3 = u"@Hell36#" print str3.isdecimal ()

Output

輸出量

TrueFalseFalse

Reference: String isdecimal()

參考: 字符串isdecimal()

翻譯自: https://www.includehelp.com/python/string-isdecimal-method-with-example.aspx

總結

以上是生活随笔為你收集整理的Python字符串| isdecimal()方法与示例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。