首页 > 编程语言 > 详细

python-函数-写函数,检查传入的字符串是否含有空字符串,返回结果,包含空字符串返回True,不包含返回False

时间:2020-06-26 15:02:36      阅读:211      评论:0      收藏:0      [点我收藏+]
‘‘‘
写函数,检查传入的字符串是否含有空字符串,返回结果,包含空字符串返回True,不包含返回False
例如:
传入:"hello world"
返回:True
‘‘‘

def a(s):
    if isinstance(s,str) or isinstance(s,list) or isinstance(s,tuple):
        for i in s:
            #if i==‘ ‘:
            if i.isspace():
                return true
            else:
                return False
    #else:
        #return None
l3=["hello world"]
ret=a(l3)
print(ret)

 

python-函数-写函数,检查传入的字符串是否含有空字符串,返回结果,包含空字符串返回True,不包含返回False

原文:https://www.cnblogs.com/cy-zjs/p/13194920.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!