标签: python
我有文件的完整路径,我需要单独获取文件名。请建议。
path = 'C:\Users\Desktop\New folder\10Jul14_14706pm\file.txt'
预期结果filename = file.txt
filename = file.txt
答案 0 :(得分:0)
感谢大家的投入,
path = r'C:\Users\Desktop\New folder\10Jul14_14706pm\file.txt' path.split('\\')[-1]
返回file.txt
file.txt