欢迎加入QQ讨论群258996829
麦子学院 头像
苹果6袋
6
麦子学院

python对方法的迭代

发布时间:2017-08-25 16:02  回复:0  查看:2151   最后回复:2017-08-25 16:02  
本文和大家分享的主要是python 中对方发的迭代相关内容,一起来看看吧,希望对大家 学习python有所帮助。
  Return True if any element of the iterable is true. If the iterable is empty, return False. Equivalent to:
  ( 返回 True ,如果 iterable 中的任何一个 element True 。如果 iterable 是空的,返回 False 。等价与: )
   def  any(iterable):
   for element  in iterable:
   if element:
   return  True
   return  False
  对一个可迭代的对象,要想知道其中某一个元素是否符合某一个表达式,用  any()  ,最好不过了。
   for
  今天才知道,原来for 循环还可以对方法进行循环,尽管之前就知道 list 中什么都可以放,可是放方法
  的还是头会见到,学习的路果然是任重而道远。
   实际运用
   问题:
  You are given a string S.
  Your task is to find out if the string S contains: alphanumeric characters, alphabetical characters, digits, lowercase and uppercase characters.
  给你一个string S
  你的任务是判断string S 是否包含: 数字字母都有 按字母表顺序 (Unicode)  有数字 有小写字母 有大写字母
   for method  in [ str.isalnum,  str.isalpha,  str.isdigit,  str.islower,  str.isupper]:
  print any(method(c)  for c  in s)
来源:Zhuhao's Blog
您还未登录,请先登录

热门帖子

最新帖子