day11.3分页操作divmod

时间:2021-04-14 22:28:29
# 分页显示 divmod(被除数,除数)
INFO_LIST = []
for i in range(836):
template = "第%s天,笨笨先僧 always be there with you" % i,
# print(template)
INFO_LIST.append(template) per_page_count = 10
total_page, rem = divmod(836, per_page_count)
if rem > 0:
total_page = total_page + 1 # 计算出总页数
# 输入页数 显示
while True:
val = input("请输入页数:") val = int(val)
if val>total_page_count or val<1
start = (val - 1) * per_page_count
end = val * per_page_count
for ele in range(start, end):
print(INFO_LIST[ele])