page
Posted 十年闷油瓶
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了page相关的知识,希望对你有一定的参考价值。
#coding:utf-8 #pagenum_count 总页数,pageshow_num 当前显示页 ,pagenum_step 一次最多显示几页 def showpagestr(pagenum_count,pageshow_num,pagenum_step): retstr = ‘‘ if pagenum_count == 1: return retstr else: if pageshow_num == 1: lastpage = pagenum_step if pagenum_count < pagenum_step: lastpage = pagenum_count retstr += ‘<strong> 1 </strong>‘ for i in xrange(2,lastpage+1): temp = "<a href=‘/list/" + str(i) + "‘ > " + str(i) + " </a>" retstr += temp if lastpage < pagenum_count: retstr += "<a href=‘/list/" + str(lastpage+1) + "‘ > " + ‘...‘ + " </a>" retstr += "<a href=‘/list/" + str(pageshow_num+1) + "‘ > " + ‘Next‘ + " </a>" retstr += "<a href=‘/list/" + str(pagenum_count) + "‘ > " + ‘End‘ + " </a>" return retstr elif pageshow_num == pagenum_count: retstr += "<a href=‘/list/1‘> " + ‘Start‘ + " </a>" retstr += "<a href=‘/list/" + str(pageshow_num-1) + "‘ > " + ‘Prev‘ + " </a>" if pageshow_num > pagenum_step: retstr += "<a href=‘/list/" + str(pageshow_num-1) + "‘ > " + ‘...‘ + " </a>" if pagenum_count > pagenum_step: i = pagenum_count % pagenum_step for i in xrange(pagenum_count-i+1,pagenum_count): temp = "<a href=‘/list/" + str(i) + "‘ > " + str(i) + " </a>" retstr += temp else: for i in xrange(1,pagenum_count): temp = "<a href=‘/list/" + str(i) + "‘ > " + str(i) + " </a>" retstr += temp retstr += "<strong> " + str(pagenum_count) + " </strong>" return retstr elif 1<pageshow_num< pagenum_count: print(showpagestr(4,4,5))
以上是关于page的主要内容,如果未能解决你的问题,请参考以下文章