查找手机号
2019獨角獸企業重金招聘Python工程師標準>>>
def _lookup_phone(self, phone_num):phone_num = str(phone_num)assert 7 <= len(phone_num) <= 11int_phone = int(str(phone_num)[0:7])left = 0right = self.phone_record_countwhile left <= right:middle = int((left + right) / 2)current_offset = int(self.first_phone_record_offset + middle * self.phone_fmt_length)if current_offset >= len(self.buf):returnbuffer = self.buf[current_offset: current_offset + self.phone_fmt_length]cur_phone, record_offset, phone_type = struct.unpack(self.phone_fmt,buffer)if cur_phone > int_phone:right = middle - 1elif cur_phone < int_phone:left = middle + 1else:record_content = get_record_content(self.buf, record_offset)return Phone._format_phone_content(phone_num, record_content,phone_type)轉載于:https://my.oschina.net/donngchao/blog/3003697
總結
- 上一篇: Linux系列开坑记(二)-神的编辑器V
- 下一篇: CentOS6.8网络接口配置文件ifc