解锁式学习
1人加入学习
(0人评价)
Python基础知识学习
价格 免费
该课程属于 949-刘同学-python方向-python数据分析-就业:否 请加入后再学习

csv

 

import csv

from collections import namedtuple

 

 

def csv_read()

    with open('product.csv',encoding = 'utf8') as f:

        reader = csv.reader(f)

        headers = next(reader)

        print(headers)

        for row in reader:

            print('编号{}\t产品{}\t单价{}'.format(row[0],row[1],row[3]))

 

def csv_read_by_namedtuple():

    with open('product.csv', encoding = 'utf8') as f:

        reader = csv.reader(f)

        headers = next(reader)

        Row = namedtuple('Row', headers)

        for r in reader:

            row = Row (*r)

            print(row)

            for row in reader:

                print(row)

 

def csv_read_by_dict():

    with open('product.csv',encoding = 'utf8') as f:

        reader = csv.DictReader(f)

 

 

 

if __name__ =='__main__':

    csv_read()

[展开全文]

授课教师

高级算法工程师
老师

课程特色

视频(61)
考试(14)
练习(12)

最新学员