标签:pytho ble 技术 code csv 打印 with user with open
三种方式读取CSV文件
准备工具:CSV文件
一:普通方法
with open(‘user.csv‘)as f: for l in f: print(l)
打印结果:
二:CSV标准库读取
import csv csv_read = csv.reader(open(‘user.csv‘)) for i in csv_read: print(i)
打印结果
三:pandas库读取
import pandas as pd data = pd.read_csv(‘user.csv‘) print(data) print(‘‘) data1 = pd.read_table(‘user.csv‘,sep=",") print(data1)
打印结果:
标签:pytho ble 技术 code csv 打印 with user with open
原文地址:https://www.cnblogs.com/hy546880109/p/13053641.html