如何在python中检查字符串是否为空? [英] How to check if a string is empty in python?
本文介绍了如何在python中检查字符串是否为空?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何检查python中的字符串是否为空?
if(s =="")??
How to check if a string is empty in python?
if(s == "") ??
推荐答案
一个简单的
如果s:
print" not empty"
else:
打印空
即可。
-Basilisk96
A simple
if s:
print "not empty"
else:
print "empty"
will do.
-Basilisk96
5月2日下午1点35分,noagbodjivic ... @ gmail.com写道:
On May 2, 1:35 pm, noagbodjivic...@gmail.com wrote:
如何查看字符串是否为空在python中?
if(s =="")??
How to check if a string is empty in python?
if(s == "") ??
空字符串和容器都是假的;所以
可以写一下
if(not s):
print" something ..."
-
希望这会有所帮助,
史蒂文
Empty strings and containers are false; so
one can write
if (not s):
print "something..."
--
Hope this helps,
Steven
5月2日,下午3:49,Basilisk96< basilis ... @ gmail.comwrote:
On May 2, 3:49 pm, Basilisk96 <basilis...@gmail.comwrote:
一个简单的
如果s :
打印非空
否则:
打印空
会做。
A simple
if s:
print "not empty"
else:
print "empty"
will do.
你怎么知道s是一个字符串?
How do you know that s is a string?
>
-Basilisk96
>
-Basilisk96
这篇关于如何在python中检查字符串是否为空?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文