python读取csv文件多行代码示例
时间: 2023-09-10 21:12:38 浏览: 157
怎么用python读取csv文件
Here is an example of reading multiple lines from a CSV file in Python:
```
import csv
with open('data.csv', 'r') as file:
reader = csv.reader(file)
for row in reader:
print(row)
```
This code will read the `data.csv` file and print each row as a list of values. The `csv.reader` function is used to create a reader object that can be used to iterate over the rows in the file. The `with` statement is used to ensure that the file is properly closed after it has been read.
阅读全文