1. iter()
用来帮助判断某元素是否在字符串中。
iter()
returns an iterator for the given object. The iter() method creates an object which can be iterated one element at a time. These objects are useful when coupled with loops like for loop, while loop.
举例如果查找某一个元素是否在字符串中,可以将此字符串变成可迭代对象。注意只能往前,不能回头,如图:
用法可以配合for loop ,while loop:
s = 'ahd'
t = 'ahbgdce'
[_ in t