C/C++教程

20220328-day18:读取excel实现分页功能

本文主要是介绍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)
这篇关于20220328-day18:读取excel实现分页功能的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!