python怎么读取csv用read
时间: 2023-12-01 21:42:17 浏览: 112
python读取csv文件方法
以下是两种Python读取CSV文件的方法:
1. 使用csv库
```python
import csv
import codecs
with codecs.open('file.csv', encoding='utf-8-sig') as f:
reader = csv.reader(f)
for row in reader:
print(row)
```
2. 使用pandas库
```python
import pandas as pd
df = pd.read_csv('file.csv')
print(df)
```
阅读全文