码迷,mamicode.com
首页 > Web开发 > 详细

python对方法的迭代

时间:2017-08-25 16:03:21      阅读:272      评论:0      收藏:0      [点我收藏+]

标签:

本文和大家分享的主要是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

python对方法的迭代

标签:

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
jiangjie190
加入时间:2016-02-19
  关注此人  发短消息
文章分类
jiangjie190”关注的人------(0
jiangjie190”的粉丝们------(0
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!