20220328-day18:读取excel实现分页功能
作者:互联网
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
VIDEO_FILE_PATH = os.path.join(BASE_DIR, 'db', 'video.csv')
print(BASE_DIR)
print(VIDEO_FILE_PATH)
page_num = 2
per_page_count = 10
start_index = (page_num - 1) * per_page_count # 10
end_index = page_num * per_page_count # 20
data_list = []
read_row_count = 0
with open(VIDEO_FILE_PATH, mode='r', encoding='utf-8') as file_object:
for line in file_object:
# print(line)
print("for循环开始的次数:",read_row_count)
if start_index <= read_row_count < end_index:
print("里面的循环:",read_row_count)
data_list.append(line.strip())
if read_row_count >= end_index:
print("break的循环:",read_row_count)
break
read_row_count += 1
print(data_list)
标签:count,index,20220328,read,excel,print,day18,page,row 来源: https://www.cnblogs.com/willguke/p/16068723.html