摘要: python provides a general purpose HOP,map simple form-a unary function and a collection of suitable arguments 代码: for e in map(abs,[1,-2,3,-4]): print 阅读全文
posted @ 2017-12-04 20:37 爱学英语的程序媛 阅读(181) 评论(0) 推荐(0)
摘要: 在讲is和==这两种运算符区别之前,首先要知道Python中对象包含的三个基本要素,分别是:id(身份标识)、python type()(数据类型)和value(值)。is和==都是对对象进行比较判断作用的,但对对象比较判断的内容并不相同。下面来看看具体区别在哪。 Python中比较两个对象是否相等 阅读全文
posted @ 2017-12-04 17:22 爱学英语的程序媛 阅读(168) 评论(0) 推荐(0)
摘要: avoid mutating a list as you are iterating over it 代码: def remove_dups(L1,L2): for e in L1: if e in L2: L1.remove(e) L1=[1,2,4,5]L2=[2,3,1,6]remove_du 阅读全文
posted @ 2017-12-04 17:17 爱学英语的程序媛 阅读(225) 评论(0) 推荐(0)
摘要: Sorting Lists sorted(iterable,key=None,reverse=False),does not mutate list, must assign result to a variable(返回新的列表,对所有可迭代的对象均有效) sort(key=None,revers 阅读全文
posted @ 2017-12-04 16:38 爱学英语的程序媛 阅读(187) 评论(0) 推荐(0)