Home >Backend Development >Python Tutorial >[python][os] Separate file directories, file names and file suffixes

[python][os] Separate file directories, file names and file suffixes

高洛峰
高洛峰Original
2017-02-21 10:08:461846browse

import os
file_path = "D:/test/test.py"(filepath,tempfilename) = os.path.split(file_path)
(filename,extension) = os.path.splitext(tempfilename)

Where:

filepath is the directory of the file, that is, D:/test

filename is the name of the file, that is, test

extension is the extension of the file, That is.py

For more articles related to [python][os] separation of file directories, file names and file suffixes, please pay attention to the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn