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

高洛峰
Release: 2017-02-21 10:08:46
Original
1831 people have browsed it

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

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template