【发布时间】:2022-08-05 13:30:38
【问题描述】:
我的 csv 文件:
Measure Names
State
WFH
Audit
State
WFH
Audit
State
WFH
Audit
State
WFH
Audit
State
WFH
Audit
State
WFH
Audit
我的预期输出:
List=[\'State\',\'WFH\',\'Audit\']
我不想使用 Pandas 库..我只允许使用默认包。
我的 csv 文件:
Measure Names
State
WFH
Audit
State
WFH
Audit
State
WFH
Audit
State
WFH
Audit
State
WFH
Audit
State
WFH
Audit
我的预期输出:
List=[\'State\',\'WFH\',\'Audit\']
我不想使用 Pandas 库..我只允许使用默认包。
import pandas as pd
s = """Measure Names
State
WFH
Audit
State
WFH
Audit
State
WFH
Audit
State
WFH
Audit
State
WFH
Audit
State
WFH
Audit"""
with open ('file.csv', 'w') as f:
f.write(s)
result = list(set(pd.read_csv('file.csv')['Measure Names']))
print(result)
印刷
['WFH', 'State', 'Audit']
【讨论】: