Use set to key vowels,usevowels,import setsc
Use set to key vowels,usevowels,import setsc
import setsclass Keeper(object): def __init__(self, keep): self.keep = sets.Set(map(ord, keep)) def __getitem__(self, n): if n not in self.keep: return None return unichr(n) def __call__(self, s): return s.translate(self)makefilter = Keeperif __name__ == '__main__': just_vowels = makefilter('aeiouy') print just_vowels(u'four score and seven years ago') print just_vowels(u'tiger, tiger burning bright')
- Load bitmap into a Canvas,bitmapcanvas,from Tkinter
- Parameter passing: mixed with dictionary and tuple,par
- Nested if statement,nestedifstatement,x = 1if x:
- List offset: start at zero, negative and slicing,negat
- List: Length, Minimum, and Maximum,minimummaximum,numb
- A function definition,functiondefinition,def square(x
热门文章:
相关内容
- Load bitmap into a Canvas,bitmapcanvas,from Tkinter
- Parameter passing: mixed with dictionary and tuple,parametertuple,d
- Nested if statement,nestedifstatement,x = 1if x:
- List offset: start at zero, negative and slicing,negativeslicing,L
- List: Length, Minimum, and Maximum,minimummaximum,numbers = [1
- A function definition,functiondefinition,def square(x
- Dictionary: clear method removes all items from the dictionary,remo
- Dictionary Keys Are Case-Sensitive,keyscase-sensitive,d = {} d['ke
- Mouse events on a frame: Mouse clicked, position,eventsclicked,from
- Read a file line by line,fileline,file = open(
评论关闭