标签:
#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))
标签:
原文地址:http://www.cnblogs.com/newpython/p/5866331.html