用正则表达式 截取你题目的解答代码如下:(如有帮助,望采纳!谢谢! 点击我这个回答右上方的【采纳】按钮)
import re txt = ''' 00_001559_automobile.png 00_001679_truck.png 00_001789_packet_boat.png ''' res = re.findall(r'^[0-9_]+([a-zA-Z_]+)',txt,re.M) print(res)