content of the csv file
A_B_C,B,C
D_2_4,E,F
import csv
with open('testfile.csv') as csvDataFile:
csvReader = csv.reader(csvDataFile)
for row in csvReader:
#if csvReader.line_num==1:
#continue
g=row[0].split("_")
print("".join(g[0:1]))
output
A
D
不晓得为什么这里join结果不是
AB
D2