csv数据文件读出来是列表,怎么去除第一行的文字描述my_list[1:]
def read_csv_2(self, filename): my_list = [] f = open(filename, 'r', encoding='UTF-8') csv_context = csv.reader(f) for csv_con in csv_context: my_list.append(csv_con) my_lists = my_list[1:] f.close() return my_lists
列表的切割:
list = [0, 1, 2, 3, 4, 5, 6, 7, 8]print("list[-1:]: ", list[-1:])print("list[:-1]: ", list[:-1])print("list[0:2]: ", list[0:3])list[-1:]: [8]list[:-1]: [0, 1, 2, 3, 4, 5, 6, 7]list[0:2]: [0, 1, 2]