import pandas as pd s = '2023-03-06_11.34.42' strP = 'D:/Projects/POM/DATA/search/' + s + '/' strFn = s + '_mm.xlsx' strP = 'D:/Projects/POM/DATA/2023年3月/两会/敏感词3月13日/上报/' strFn = 'MGC2023.3.13.xlsx' df = pd.read_excel(strP+strFn) print(strP+strFn) print(df.shape) cities = df['市州'].unique() print(cities) for city in cities: print(city) dft = df[df['市州'].isin([city])] print(dft.shape) # exec("df%s = dft"%cityNum) dft.to_excel(strP + city+'.xlsx', index= False)