input_file = r"C:\Users\Administrator\Desktop\python-master\csv\supplier_data.csv"
#r代表不转义,如果不加r那么""中就要加双反斜杠。
output_file = r"C:\Users\Administrator\Desktop\abc.txt"
important_dates = ['1/20/14', '1/30/14']
with open(input_file, 'r', newline='') as csv_in_file:
with open(output_file, 'w', newline='') as csv_out_file:
filereader = csv.reader(csv_in_file)
filewriter = csv.writer(csv_out_file)
header = next(filereader)
filewriter.writerow(header)
for row_list in filereader:
a_date = row_list[4]
if a_date in important_dates:
filewriter.writerow(row_list)
C:\Users\Administrator>cd Desktop\python-master\csv
C:\Users\Administrator\Desktop\python-master\csv>python 4csv_reader_value_in_set.py supplier_data.csv aa.txt