python路径分割字符串

将路径和文件名分开:os.path.split()

分2中路径:

1.path='/abc/test/'

import os

os.path.split(path),得到元组('/abc/test','')

2.path='/abc/test'

import os

os.path.split(path),得到元组('/abc','test').元组的第2个元素为文件名

posted @ 2017-03-31 17:41  水工  阅读(3342)  评论(0编辑  收藏  举报