日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
Python 程序:檢查字符是否為數(shù)字

創(chuàng)新互聯(lián)python教程:

創(chuàng)新互聯(lián)公司是一家集網(wǎng)站建設(shè),霍州企業(yè)網(wǎng)站建設(shè),霍州品牌網(wǎng)站建設(shè),網(wǎng)站定制,霍州網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營(yíng)銷,網(wǎng)絡(luò)優(yōu)化,霍州網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。

用一個(gè)實(shí)例編寫一個(gè) Python 程序來(lái)檢查字符是不是數(shù)字。

Python 程序檢查字符是否為數(shù)字

這個(gè) python 程序允許用戶輸入任何字符。接下來(lái),我們使用 If Else 語(yǔ)句來(lái)檢查用戶給定的字符是否是數(shù)字。這里, If 語(yǔ)句檢查字符是否大于等于 0,小于等于 9。如果為真,則為數(shù)字。否則,它不是一個(gè)數(shù)字。

# Python Program to check character is Digit or not
ch = input("Please Enter Your Own Character : ")

if(ch >= '0' and ch <= '9'):
    print("The Given Character ", ch, "is a Digit")
else:
    print("The Given Character ", ch, "is Not a Digit")

Python 字符是數(shù)字還是不輸出

Please Enter Your Own Character : 1
The Given Character  1 is a Digit
>>> 
Please Enter Your Own Character : i
The Given Character  i is Not a Digit

Python 程序使用 ASCII 值查找字符是否為數(shù)字

在本 Python 示例中,我們使用 ASCII 值來(lái)檢查字符是否為數(shù)字。

# Python Program to check character is Digit or not
ch = input("Please Enter Your Own Character : ")

if(ord(ch) >= 48 and ord(ch) <= 57):
    print("The Given Character ", ch, "is a Digit")
else:
    print("The Given Character ", ch, "is Not a Digit")
Please Enter Your Own Character : 7
The Given Character  7 is a Digit
>>> 
Please Enter Your Own Character : @
The Given Character  @ is Not a Digit

使用數(shù)字函數(shù)驗(yàn)證字符是否為數(shù)字的 Python 程序

在本例 python 代碼中,我們使用 If Else 語(yǔ)句中的 isdigit 字符串函數(shù)來(lái)檢查給定字符是否為數(shù)字。

# Python Program to check character is Digit or not
ch = input("Please Enter Your Own Character : ")

if(ch.isdigit()):
    print("The Given Character ", ch, "is a Digit")
else:
    print("The Given Character ", ch, "is Not a Digit")


分享題目:Python 程序:檢查字符是否為數(shù)字
轉(zhuǎn)載注明:http://www.dlmjj.cn/article/cddejoj.html