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 OS module introduction, pythonos Module
OS. getcwd () obtains the current working directory, that is, the directory path of the current python script.
OS. chdir ("dirname") changes the current script working directory, which is equivalent to
Python OS module and Pythonos ModulePython OS Module 1. OS. getcwd ()
Obtain the current working directory.
ImportOS
Print (OS. getcwd () # I: \ Python ProgramIi. OS. chdir ('path ')
Change the working directory of the current script. It is
Python3 OS module & sys module & hashlib module, python3os Module
1 '''2 OS Module 3 very important module 4 '''5 import OS 6 # print (OS. getcwd () # Get the current working directory 7 # OS. chdir (r 'pathname') # change the current working
Common functions for file/directory in the OS Module
Function Name
Usage
Getcwd ()
Back to current working directory
Chdir (PATH)
Change working directory
Listdir (Path = '.')
List the file names in
Python system modules include sys, OS, glob, socket, threading, _ thread, queue, time, timeit, subprocess, Multiprocessing, signal, select, shutil, and tempfile. Most system-level interfaces are concentrated in the SYS and OS modules.
The SYS
OS module Introduction The OS module is a module used to access operating system functions in the Python standard library. The OS module provides a portable Method for operating system functions. The interface provided in the OS module can be used
Day6 OS module, day6os
OS Module
Provides an interface for calling the operating system.
(1) OS. getcwd () obtains the current working directory, that is, the directory path of the current python script.
>>> OS. getcwd () obtains the directory 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
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.