filepath = 'C:\Documents\2.jpg' imageID = re.split(r'\\', filepath[2:-4])[-1] 在Python字符串中,使用两个反斜杠转义,即可表示一个反斜杠