pagination.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:sdining 作者: Lurance 项目源码 文件源码
def encode_cursor(self, cursor):
        """
        Given a Cursor instance, return an url with encoded cursor.
        """
        tokens = {}
        if cursor.offset != 0:
            tokens['o'] = str(cursor.offset)
        if cursor.reverse:
            tokens['r'] = '1'
        if cursor.position is not None:
            tokens['p'] = cursor.position

        querystring = urlparse.urlencode(tokens, doseq=True)
        encoded = b64encode(querystring.encode('ascii')).decode('ascii')
        return replace_query_param(self.base_url, self.cursor_query_param, encoded)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号