上一页 1 ··· 3 4 5 6 7 8 9 下一页
摘要: timedelta() timedelta方法可以表示一个时间段,并可以进行计算,而且可以直接对datetime计算。 例子: today() datetime的today函数可以表示现在的时间。 例子: timezone(str) pytz的这个方法可以生成时区对象以供使用。 例子: type(o 阅读全文
posted @ 2018-07-19 19:30 Small_office 阅读(289) 评论(0) 推荐(0) 编辑
摘要: slice(int,int) 切片,可以为切片命名增加可读性。 例子: sorted(iterable, key) 排序,支持传入参数,例如通过itemgetter传入参数(itemgetter可以传入多个key)。 例子: 利用attrgetter可以比较不支持原生比较的,比如类。 sum(ite 阅读全文
posted @ 2018-07-19 19:29 Small_office 阅读(450) 评论(0) 推荐(0) 编辑
摘要: replace(str, str) 字符串替换。 例子: rjust(int) 格式化字符串,右对齐,支持传入填充值。 例子: rstrip(str) 删去右边的参数,支持传入参数。 例子: round(float,int) 舍入运算,python基本就是四舍五入,但是在python3时边界中间时会 阅读全文
posted @ 2018-07-19 19:18 Small_office 阅读(143) 评论(0) 推荐(0) 编辑
摘要: popleft(iterable) 对应pop,左侧弹出,队列适用。 例子: permutations(iterable, int) itertools的permutations方法可以产生集合的所有排列,并且接受一个参数来指定长度。 例子: partial(str, int) functools的 阅读全文
posted @ 2018-07-19 19:16 Small_office 阅读(145) 评论(0) 推荐(0) 编辑
摘要: OrderedDict() 保持dict元素插入顺序。 例子: open(path) 可以对文件进行操作,有'r'读模式、'w'写模式、'a'追加模式、'b'二进制模式、'+'读/写模式等,操作完需要close。 例子: os模块 os模块包含普遍的操作系统功能,介绍几种常用功能,因path用的较多 阅读全文
posted @ 2018-07-19 19:11 Small_office 阅读(101) 评论(0) 推荐(0) 编辑
摘要: nlargest(int , iterable,key) 查找最大的n个元素。 例子: 还支持传入key进行复杂元素比较:如:nlargest (n, list,key=lambda a:a[b])。 nsmallest(int , iterable, key) 查找最小的n个元素。 例子: 还支持 阅读全文
posted @ 2018-07-19 19:10 Small_office 阅读(225) 评论(0) 推荐(0) 编辑
摘要: max(iterable) 求最大值,可以传入key。 例子: min(iterable) 求最小值,支持传入key。 例子: match(regular expression, string) 字符串正则表达式复杂匹配。 例子: merge(iterable, iterable..) heapq的 阅读全文
posted @ 2018-07-19 19:09 Small_office 阅读(289) 评论(0) 推荐(0) 编辑
摘要: lstrip(str) 删除字符串左边的字符,支持传入参数。 例子: ljust(int) 格式化字符串,左对齐,支持传入填充值。 例子: loads(json) 将json字符串转换为dict。 例子: 阅读全文
posted @ 2018-07-19 19:08 Small_office 阅读(167) 评论(0) 推荐(0) 编辑
摘要: (1)join(iterable)/(2) join(str, str) (1)join()连接字符串数组.(2)os.path.join()将多个路径组合后返回。 例子: 阅读全文
posted @ 2018-07-19 19:07 Small_office 阅读(129) 评论(0) 推荐(0) 编辑
摘要: iter(iterable) 可以生成一个迭代器。 例子: islice(iterator, int, int) itertools的islice方法为迭代器生成器提供切片操作。 例子: izip_longest(iterable, iterable) itertools的izip_longest方 阅读全文
posted @ 2018-07-19 19:06 Small_office 阅读(147) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 下一页