#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Created by 秋葉夏風# 本模塊的功能:<>def get_page_list(max_page,curr_page,leng):'''用于生成頁數列表:param max_page:最大頁數:param curr_page:當前頁數:param leng:分頁步長:return:list'''# max_page = 20# curr_page = 18# leng = 3page_list = []if curr_page in range(leng+1,max_page-leng+1):k = 0elif curr_page > max_page / 2:k = max_page - curr_page - leng + 1elif curr_page < max_page / 2:k = leng - curr_page + 1for i in range(0-leng,leng):j = curr_page + i + kpage_list.append(j)print(page_list)return page_listif __name__ == '__main__':get_page_list(100,21,5)'''┌─┐ ┌─┐ + +┌──┘ ┴───────┘ ┴──┐++│ ││ ─── │++ + + +███████───███████ │+│ │+│ ─┴─ ││ │└───┐ ┌───┘│ ││ │ + +│ ││ └──────────────┐│ ││ ├─┐│ ┌─┘│ │└─┐ ┐ ┌───────┬──┐ ┌──┘ + + + +│ ─┤ ─┤ │ ─┤ ─┤└──┴──┘ └──┴──┘ + + + +神獸保佑代碼無BUG!'''
作者:秋葉夏風
出處:https://blog.csdn.net/qq_40223983
本文版權歸作者和CSDN博客共有。歡迎轉載,但必須保留此段聲明,且在文章頁面明顯位置給出原文連接!