关于翻页问题
我在控制台上显示的有两页,但是输入 next 之后第二页没有内容,我数据库里面有16条内容
app.py
from colorama import Fore, Style
from getpass import getpass
from service.user_service import UserService
from service.news_servcie import NewsService
import os
import sys
import time
__user__service = UserService()
__news_service = NewsService()
while True:
os.system("clear")
print(Fore.LIGHTBLUE_EX, "\n\t=======================")
print(Fore.LIGHTBLUE_EX, "\n\t欢迎使用新闻管理系统 ")
print(Fore.LIGHTBLUE_EX, "\n\t=======================")
print(Fore.LIGHTGREEN_EX, "\n\t1.登录系统")
print(Fore.LIGHTGREEN_EX, "\n\t2.退出系统")
print(Style.RESET_ALL)
opt = input("\n\t输入操作编号:")
if opt == '1':
username = input("\n\t用户名:")
password = getpass("\n\t密码:")
result = __user__service.login(username, password)
# 登录成功
if result == True:
# 查询角色
role = __user__service.search_user_role(username)
os.system("clear")
while True:
if role == "新闻编辑":
print("test")
elif role == "管理员":
print(Fore.LIGHTGREEN_EX, "\n\t1.新闻管理")
print(Fore.LIGHTGREEN_EX, "\n\t2.用户管理")
print(Fore.LIGHTRED_EX, "\n\tback. 退出登录")
print(Fore.LIGHTRED_EX, "\n\texit.退出系统")
print(Style.RESET_ALL)
opt = input("\n\t输入操作编号:")
if opt == "1":
while True:
os.system("clear")
print(Fore.LIGHTGREEN_EX, "\n\t1.审批新闻")
print(Fore.LIGHTGREEN_EX, "\n\t2.删除新闻")
print(Fore.LIGHTRED_EX, "\n\tback. 返回上一层")
print(Style.RESET_ALL)
opt = input("\n\t输入操作编号:")
if opt == "1":
page = 1
while True:
os.system("clear")
count_page = __news_service.search_unreview_count_page()
result = __news_service.search_unreview_list(page)
for index in range(len(result)):
one = result[index]
print(Fore.LIGHTBLUE_EX, "\n\t%d\t%s\t%s\t%s" % (index + 1, one[1], one[2], one[3]))
print(Fore.LIGHTBLUE_EX, "\n\t-------------------")
print(Fore.LIGHTBLUE_EX, "\n\t%d/%d" % (page, count_page))
print(Fore.LIGHTBLUE_EX, "\n\t-------------------")
print(Fore.LIGHTRED_EX, "\n\tback. 返回上一层")
print(Fore.LIGHTRED_EX, "\n\tprev. 返回上一页")
print(Fore.LIGHTRED_EX, "\n\tnext. 返回下一页")
print(Style.RESET_ALL)
opt = input("\n\t输入操作编号:")
if opt == "back":
break
elif opt == "prev" and page > 1:
page -= 1
elif opt == "next" and page < count_page:
page += 1
elif opt == "back":
break
elif opt == "exit":
sys.exit(0)
else:
print("\n\t登录失败(5秒之后自动返回)")
time.sleep(5)
elif opt == "2":
sys.exit(0)
正在回答 回答被采纳积分+1
- 参与学习 人
- 提交作业 625 份
- 解答问题 2669 个
数据库作为企业储存和管理数据的根本,掌握数据库是每个开发工程师必备的技能,本阶段带你学会用Python操作MySQL、Redis和MongoDB三大主流数据库。夯实数据库基础。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星