2024-07-07 08:05:24 发布
网友
例如: 我有阿肯色州及其一些县的名单如下:
ar randolph franklin lawrence scott sharp carroll greene van buren clay montgomery cleburne fulton polk boone madison marion baxter searcy stone newton
州是列表开头的两个字母缩写。在本例中,我如何使这些县中的每个县都附加“ar”,例如,伦道夫,ar;富兰克林,阿肯色州;牛顿等
list_of_counties = ['ar', 'franklin', .....] list_to_append = [] for county in list_of_counties: if len(county) == 2: abbreviation = ' ,' + county else: list_to_append.append(county + abbreviation)
这是一个缩写,在列表中排在第一位
这是一个缩写,在列表中排在第一位
相关问题 更多 >
编程相关推荐