str = " abcdefg " str.strip() #用于去掉字符串两边的空格 2**2 #output 4 3**2 #output 9 由这两式可知,两个*是算次方 [x*10 for i in range(1,5)] #output 10,20,30,40,50 [[x,x*10] for i in range(1,5)] #output [1,10],[2,20],[3,30],[4,40],[5,50] >>> a = set('abracadabra') >>> b = set('alacazam') >>> a # unique letters in a #{'a', 'r', 'b', 'c', 'd'} >>> a = {x for x in 'abracadabra' if x not in 'abc'} >>> a {'r', 'd'}