1. Understand OS. path. dirname (_ file __)
Obtain the path name:OS. path. dirname ()
Obtain the complete path of the directory where the file is located: OS. path. dirname (_ file __)
You can also configure settings. py in the django project as
Summary of OS Operating Files and file path instances in python,
This article describes the operating file and file path methods in python. Share it with you for your reference. The specific analysis is as follows:
Python obtains the upper-level
The OS. path module mainly integrates the path folder operation function. here we will take a look at the operation method summary in the OS. path module in Python. For more information, see
Resolution pathPath parsing dependency and some variables
Python standard library OS. path package, glob package use instance, OS. pathglob
OS. path package
The OS. path package is mainly used to process string paths, such as '/home/zikong/doc/file.doc' to extract useful information.
Copy codeThe Code is
This article mainly introduces the Python standard library OS. path package and glob package usage examples. This article provides the code directly. the code contains detailed comments. For more information, see
OS. path package
The OS. path
Author: vamei Source: http://www.cnblogs.com/vamei welcome reprint, please also keep this statement. Thank you!
1. Introduction to paths and files
See Linux File System
Http://www.cnblogs.com/vamei/archive/2012/09/09/2676792.html
2. OS. Path
1:OS. Listdir (PATH) // path is the Directory
The function is equivalent to executing the Dir command in the path directory. The returned result is of the list type.PrintOS. Listdir ('..')
2:OS. Path.Walk(Path, visit, ARG)
Path: the
Python module OS, pythonos
The OS module allows you to create, delete, and view file attributes for directories or files, as well as perform path operations on files and directories. For example: absolute path, parent directory ......
OS. sep can
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.