It seems like a particularly bizarre constraint to be able to use DictReader
but not use its fieldnames
value. Anyway, just open the csv file as a normal CSV and read the first row - this gives you the field names.
import csv
filepath = my_file.csv"
with open(filepath, 'r') as csvfile:
reader = csv.reader(csvfile)
for row in reader:
headerrow = list(row)
break
print(headerrow)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…