标签:sel pen git init 自定义 int stop def ota
class PageInfo: def __init__(self, num_page, total, uri, pei_page=10, show_page=11): if num_page.isdigit(): num_page = int(num_page) else: num_page = 1 self.num_page = num_page self.pei_page = pei_page self.show_page = show_page self.uri = uri a, b = divmod(total, pei_page) self.total_page = a if b: self.total_page += 1 def get_start(self): return (self.num_page - 1) * 10 def get_stop(self): return self.num_page * 10 def page(self): args = [] if self.num_page - (self.show_page // 2) < 1: start = 1 end = self.show_page + 1 elif self.num_page + (self.show_page // 2) > self.total_page: start = self.total_page - self.show_page end = self.total_page + 1 else: start = self.num_page - (self.show_page // 2) end = self.num_page + (self.show_page // 2) + 1 print(end) if self.num_page - 1 > 0: s = "<li><a href=‘/%s%s‘>上一页</a></li>" % (self.uri, self.num_page - 1) else: s = "<li class=‘disabled‘><a href=‘#‘ >上一页</a></li>" args.append(s) for i in range(start, end): if i == self.num_page: s = "<li class=‘active‘><a href=‘/%s%s‘>%s </a></li>" % (self.uri, i, i) else: s = "<li><a href=‘/%s%s‘>%s </a></li>" % (self.uri, i, i) args.append(s) if self.num_page + 1 > self.total_page: s = "<li class=‘disabled‘><a href=‘#‘ >下一页</a></li>" else: s = "<li><a href=‘/%s%s‘ >下一页</a></li>" % (self.uri, self.num_page + 1) args.append(s) return "".join(args)
标签:sel pen git init 自定义 int stop def ota
原文地址:https://www.cnblogs.com/jixu/p/11371880.html