Python学习 代码

来源:互联网 发布:windows 10 version 编辑:程序博客网 时间:2024/06/16 17:47
>>> bob =['Bob Smith',42,3000,'sofeware']>>> sue =['Sue Jones',45,4000,'hardware']>>> bob[0],sue[0]('Bob Smith', 'Sue Jones')>>> bob[0],sue[2]('Bob Smith', 4000)>>> bob[0].split()[-1]'Smith'>>> sue[2]*=1.25>>> sue['Sue Jones', 45, 5000.0, 'hardware']>>> people =[bob,sue]>>> for person in people:print(person)['Bob Smith', 42, 3000, 'sofeware']['Sue Jones', 45, 5000.0, 'hardware']>>> people[1][0]'Sue Jones'>>> for person in people:print(person[0].split()[1])person[2]*=1.20SmithJones>>> for person in people:print(person[2])3600.06000.0>>> >>> >>> pays=[person [2] for person in people]>>> pays[3600.0, 6000.0]>>> pays=map((lambda x:x[2]),people)>>> pays<map object at 0x00000000033C0208>>>> list(pays)[3600.0, 6000.0]>>> sum(person[2] for person in people)9600.0>>> people.append(['Tom',50,0,None])>>> len(people)3>>> people[-1]['Tom', 50, 0, None]>>> people[-1][0]'Tom'>>> 
原创粉丝点击