qq_花开花谢_0
date = string.split("AVE_")[-1].split(".csv")[0]解释.split("AVE_")[-1] # will take the last entry so if there is no "AVE" in front it will just leave the string as it is. ".split(".csv")[0]" # The last part strips away .csv if it exists otherwise leaves the string unchanged输出>>> my_list['AVE_2020_01_13', 'AVE_2020_01_15', 'AVE_2020_01_13', 'AVE_2020_02_10', 'AVE_2020_02_10', 'AVE_2020_02_10', '2020_01_29.csv', '2019_12_02.csv']>>> my_new_list = []>>> for entry in my_list:... my_new_list.append(entry.split("AVE_")[-1].split(".csv")[0])...>>> my_new_list['2020_01_13', '2020_01_15', '2020_01_13', '2020_02_10', '2020_02_10', '2020_02_10', '2020_01_29', '2019_12_02']