BZ易风

导航

 

 

检查字符串里是否有空格,列表、元祖里是否有空

 

 

 1 def func(x):
 2     if type(x) is str and x:         //如果type(x)是字符串且x不为空
 3         for i in x:
 4             if i == ' ':
 5                 return True
 6     elif x and type(x) is list or type(x) is tuple:
 7         for i in x:
 8             if not i:        //如果i不为空
 9                 return True    
10     elif not x:
11         return True
12 
13 
14 print(func([]))

 

posted on 2019-04-01 21:04  BZ易风  阅读(308)  评论(0编辑  收藏  举报