摘要:
python中的序列 可变序列 list、bytearray、array.array、collections.deque 和 memoryview。 不可变序列 tuple、str 和 bytes。 序列图 箭头指向的是父类,从图中可以看出: 1. 序列是可迭代的,继承了__iter__的方法,在系 阅读全文
posted @ 2018-07-29 12:23
孙龙-程序员
阅读(3119)
评论(0)
推荐(1)
摘要:
关于array: Python 本身没有数组这个说法, 有的就是list和tuple, list就具有其他语言中的数组特性. 至于list和tuple的区别,在于list可以在运行时修改内容和大小,tuple在首次创建和赋值后, 不可以再次修改内部的内容 不过python 有提供一个array模块, 阅读全文
posted @ 2018-07-29 12:21
孙龙-程序员
阅读(11682)
评论(0)
推荐(0)
摘要:
import bisect L = [1,3,3,5,7,9] x = 30 ##在L中查找x,x存在时返回x左侧的位置 x不存在返回应该插入的位置 x_insert_point = bisect.bisect_left(L,x) print(x_insert_point) #在L中查找x,x存在时返回x右侧的位置,x不存在返回应该插入的位置 x_insert_point = bisect... 阅读全文
posted @ 2018-07-29 12:15
孙龙-程序员
阅读(246)
评论(0)
推荐(0)
摘要:
1 import numbers 2 from collections import abc 3 class Group: 4 #支持切片操作 5 def __init__(self, group_name, company_name, staffs): 6 self.group_name = group_name 7 self.co... 阅读全文
posted @ 2018-07-29 12:08
孙龙-程序员
阅读(638)
评论(0)
推荐(0)
浙公网安备 33010602011771号