Python -- 获取文件所在目录和文件名

来源:互联网 发布:ce6.7源码 编辑:程序博客网 时间:2024/06/01 08:46
import osif __name__ == "__main__":    file_path = 'D:/test/test.apk'    parent_path = os.path.dirname(file_path)    print('parent_path = %s' % parent_path)    file_name = os.path.split(file_path)[-1]    print('file_name = %s' % file_name)

输出:



0 0