一个python读取文件路径最后两列的工具
file = open(r'C:\Users\MrC\Desktop\新建文本文档 (2).txt','r')
result = []
lines=file.readlines()
for line in lines:
line=line.strip()
arr=line.split('\\')
print(arr)
result.append(arr[-2]+"\\"+arr[-1])
file2 = open(r'C:\Users\MrC\Desktop\test.txt','w')
print(result)
for line in result:
file2.write(line+'\n')
file2.close()