av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

Python中判斷字符串是否為空和null常用的方法

本篇文章重點(diǎn)為大家講解一下Python中字符串是否為空和null常用的方法,有需要的小伙伴可以參考一下。

10年積累的做網(wǎng)站、成都網(wǎng)站制作經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶對(duì)網(wǎng)站的新想法和需求。提供各種問題對(duì)應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先建設(shè)網(wǎng)站后付款的網(wǎng)站建設(shè)流程,更有安源免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。

1、使用字符串長(zhǎng)度判斷

len(s) ==0 則字符串為空

#!/user/local/python/bin/python
# coding=utf-8
test1 = ''
if len(test1) == 0:
 print '字符串TEST1為空串'
else:
 print '字符串TEST1不是空串,TEST1:' + test1

2、isspace判斷是否字符串全部是空格

Python isspace() 方法檢測(cè)字符串是否只由空格組成。

#!/user/local/python/bin/python
# coding=utf-8

str = "    ";
print str.isspace();

str = "This is string example....wow!!!";
print str.isspace();

True
False

3、字符串去空格及去指定字符

去兩邊空格:str.strip()

去左空格:str.lstrip()

去右空格:str.rstrip()

#!/user/local/python/bin/python
# coding=utf-8
str = "    ";
print str.strip();
str = "This is string example....wow!!! ";
print str.strip();

網(wǎng)站名稱:Python中判斷字符串是否為空和null常用的方法
網(wǎng)站路徑:http://uogjgqi.cn/article/dhjjhog.html
掃二維碼與項(xiàng)目經(jīng)理溝通

我們?cè)谖⑿派?4小時(shí)期待你的聲音

解答本文疑問/技術(shù)咨詢/運(yùn)營(yíng)咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流