os and sys modules and the module using the method

The modular approach os

 

 os.remove () to delete the file
 os.rename () Rename the file
 os.walk () generated directory tree of all the file names
 os.chdir () to change the directory
 os.mkdir / makedirs create the directory / multi-directory
 os.rmdir / removedirs delete the directory / multi-directory
 os.listdir () lists the files in the specified directory
 os.getcwd () get the current working directory
 os.chmod () to change the directory permissions
 os.path.basename ( ) removing the directory path, file name returned
 os.path.dirname () remove the file name, directory path returned
 os.path.join () separating a packet combining each part pathname
 os.path.split () returns (dirname (), basename () ) tuple
 os.path.splitext () (returns the filename, extension) tuple
 os.path.getatime \ ctime \ mtime return the recent visit, create, modify time
 os.path .getsize () returns the file size
 os.path.exists () whether there
 os.path.isabs () whether it is an absolute path
if the directory  os.path.isdir ()

 

 

 

The method of the sys module

sys.argv command line parameters List, the first element is the path to the program itself
 sys.modules.keys () returns a list of all modules has been introduced
 sys.exc_info () Gets exception class currently being processed, exc_type, exc_value, exc_traceback currently processed
detailed abnormality information
 sys.exit (n) to exit the program, when the normal exit exit (0)
 sys.hexversion acquired Python interpreter program version value, such as hexadecimal format: 0x020403F0
 the sys.version Python interpreter acquires version information
 sys.maxint maximum value Int
 sys.maxunicode maximum Unicode values
 sys.modules return module field of system implementation, key module name, value is the module
when the module returns  sys.path search path, the initialization use PYTHONPATH environment variable value
 sys.platform return to the operating system platform name
 sys.stdout standard output
 sys.stdin standard input
 sys.stderr error output
 sys.exc_clear () is used to clear the current or the current thread that appears the most recent error message
 sys.exec_prefix return python platform-independent file installation location
 sys.byteorder this Rule pointer byte, the value of the platform is big-endian 'big', the value of little-endian platform is
'little'
 sys.copyright record python copyright-related things
 sys.api_version interpreter C API version
 sys.version_info tuple gives an easier way to make your program Python-version features
 os.path.isfile () whether the file

Guess you like

Origin www.cnblogs.com/ln-xx/p/12075375.html