在 Python 中,可以使用 csv 模块来处理 CSV 文件。
首先,需要使用 import csv
导入 csv 模块。
然后,可以使用 csv 模块中的 reader()
函数来读取 CSV 文件中的数据。例如:
import csv
with open('filename.csv', 'r') as csv_file:
csv_reader = csv.reader(csv_file)
for row in csv_reader:
print(row)