读取文件
with open(file_path, encoding='UTF-8') as file: lines = csv.reader(file, delimiter="#", quotechar='"') for row in lines: print(row)
读取list
注意:如果是字符串,一定要转成list. 例如 rows = csv.reader(["John#" #"Doe"# '21'])
import csv csv_string = 'John,Doe,21\nJane,Smith,35\nAdam,Johnson,42' rows = csv.reader(csv_string.splitlines()) first_row = next(rows) print(first_row)
标签:读取,python,list,file,reader,csv,row From: https://www.cnblogs.com/panda4671/p/17330780.html