Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Python basis: os module on the file / directory using methods commonly used functions     - Increase Linux system security --chattr (Linux)

- Ubuntu use three methods to install Ruby (Linux)

- Linux package manager - yum (Linux)

- FileZilla 3.10.1.1 install on Ubuntu 14.10 (Linux)

- NGINX Plus now fully supports HTTP / 2 (Server)

- How do you temporarily emptied Bash environment variable before running the command on Linux (Linux)

- How to use the TF / SD card making Exynos 4412 u-boot boot disk in Ubuntu (Linux)

- Ubuntu 14.04 compile RT288x_SDK / toolchain / squashfs3.2-r2 Error (Linux)

- PHP parsing algorithm of the interview questions (Programming)

- Java garbage collection (Programming)

- Check the Linux server performance with ten or so commands in a minute (Server)

- Intel Graphics Installer 1.0.3 released, support for Ubuntu (Linux)

- Cryptography development environment to build under Ubuntu (Linux)

- Install Ubuntu Software Center App Grid (Linux)

- How to upgrade the kernel to 3.13.7 on Ubuntu / Linux Mint (Linux)

- How Glances monitoring system on Ubuntu (Linux)

- Some security configuration of Linux systems (Linux)

- C ++ overloaded stream insertion operator and the stream extraction operator (Programming)

- HTML5 Fundamentals study notes (Programming)

- Android Activity launchMode (Programming)

 
         
  Python basis: os module on the file / directory using methods commonly used functions
     
  Add Date : 2018-11-21      
         
         
         
  Python is a cross-platform language, is to say the same source code on different operating systems without modification can achieve the same authors therefore Python module to shift the OS out such a thing, with the OS module, we do not need care what operating system what modules, OS module will help you select the right module and call.

os module on the file / directory using methods commonly used functions os.path module function uses methods commonly used on path

Function name
Instructions
getcwd () returns the current working directory
chdir (path) to change the working directory
listdir (path = '.') listed in the directory specified file name ( '.' means the current directory, '..' means the parent directory)
mkdir (path) to create a single directory, if the directory already exists thrown
makedirs (path) to create a multi-layer recursive directory, if the directory already exists an exception, note: 'E: \ a \ b' and 'E: \ a \ c' and does not conflict
remove (path) to delete the file
rmdir (path) to delete single directory, if the directory is not empty then thrown
removedirs (path) recursively delete the directory, subdirectory from the parent directory to try to remove the layer by layer, a non-empty directory encountered an exception is thrown
rename (old, new) will rename the new file old
system (command) operation of the system shell commands
walk (top) through all of the top path following subdirectories, returns a triple :( path [directory containing], [include file]) [see concrete implementation: After the first 30 lectures job ^ _ ^]
The following operations are commonly used to support the path of some definitions, support for all platforms
os.curdir refers to the current directory ( '.')
os.pardir refers to the parent directory ( '..')
(For the next Win '\', under Linux is '/') os.sep output operating system-specific path separator
os.linesep current line terminator platform used (for the next Win ' r n', the ' n' under Linux)
os.name refers to the current operating system used (including: 'posix', 'nt', 'mac', 'os2', 'ce', 'java')
Function name
Instructions
basename (path) to remove the directory path, file name alone returns
dirname (path) to remove the file name, directory path returned alone
join (path1 [, path2 [, ...]]) will path1, path2 ministries packet combining a pathname
split (path) Split the file name and path, the return (f_path, f_name) tuple. If full use of the directory, it will also last a separate directory as the file name, and does not determine whether a file or directory exists
splitext (path) separating the file name and extension, return (f_name, f_extension) tuples
getsize (file) Returns the specified file size in bytes
getatime (file) returns the specified file was last access time (floating-point number of seconds, the available time module gmtime () or localtime () function conversion)
getctime (file) Returns the creation time of the specified file (float number of seconds, the available time module gmtime () or localtime () function conversion)
getmtime (file) Returns the latest file modification time (floating-point number of seconds, the available time module gmtime () or localtime () function conversion)
The following is the function returns True or False
exists (path) is determined to specify the path (directory or file) exists
isabs (path) Determines whether the specified path is an absolute path
isdir (path) determine whether the specified path exists and is a directory
isfile (path) determine whether the specified path exists and is a file
islink (path) determine whether the specified path exists and is a symbolic link
ismount (path) determine whether the specified path exists and is a mount point
samefile (path1, paht2) path1 and path2 determine whether two paths point to the same file
     
         
         
         
  More:      
 
- Monitoring network traffic with Iptraf in Linux environment (Linux)
- How to install the NVIDIA 358.16 driver in Ubuntu 15.10,14.04 (Linux)
- Getting the Linux shell flow control statements (Programming)
- Oracle Database High-Risk Vulnerability Warning (Database)
- Multipath configuration under Linux (Linux)
- To install and configure the Jetty server and JDK under Ubuntu 14.04.2 (Server)
- Python regular expressions: how to use regular expressions (Programming)
- Oracle11g CRS-0184 Problem Solving (Database)
- Disk Management LVM (Linux)
- Oracle 11g contraction table space error ORA-03297: file contains used data beyondrequested RESIZE value (Database)
- Linux learning portal: CentOS 6.4 system kernel upgrade (Linux)
- Daemon under Linux (Linux)
- Formatted output printf command (Programming)
- mysql_config_editor encryption and decryption of the new features of MySQL realization (Database)
- How to install and configure a VNC server on CentOS 7.0 (Server)
- Management and application Oracle external table (Database)
- Manage SQL Server services login (start) account and password (Database)
- How to set up FTP server on Linux (Server)
- Install Ubuntu open source drawing program MyPaint 1.2.0 (Linux)
- To install Samba server on CentOS 6.6 (Server)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.