#!/usr/bin/python #coding=utf-8 ''' Created on 2013-6-14 迭代序列中的值,然后进行修改 @author: Administrator ''' #method1 使用map内建函数 def append(var): return var*4 for value in map(append,"apache") :print(value)
#method2 使用列推导式 print("split".center(20,"-")) for value in [ch*4 for ch in "apache"]:print(value)
#method3 使用lambda函数 print("split".center(20,"-"))
for value in map(lambda x :x*4,"apache") :print(value)
#method4 使用循环 print("split".center(20,"-"))
tempList = list() for ch in "apache": tempList.append(ch*4) for value in tempList: print(value)