码迷,mamicode.com
首页 > 其他好文 > 详细

page

时间:2016-09-12 22:07:34      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:

#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

标签:

原文地址:http://www.cnblogs.com/newpython/p/5866331.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!