Os.path.isabs (PATH)
Returns True if the parameter path is an absolute path , otherwise Falseis returned.
Example:
#python 3.4
From Os.path Import *
Pathstr = ' f:\\temp\\py\\cal_1.py '
R = Isabs (PATHSTR)
Print (R)
The resulting output is as follows:
True
Os.path.isfile (PATH)
Returns True if the parameter path is a file return , otherwise False.
Example:
#python 3.4
From Os.path Import *
Pathstr = ' f:\\temp\\py\\cal_1.py '
R = Isfile (PATHSTR)
Print (R)
The resulting output is as follows:
True
Os.path.isdir (PATH)
Returns True if the parameter path is a directory , otherwise False.
Example:
#python 3.4
From Os.path Import *
Pathstr = ' f:\\temp\\py\\cal_1.py '
R = Isdir (PATHSTR)
Print (R)
The resulting output is as follows:
False
Os.path.islink (PATH)
Returns True if the parameter path is a symbol entry connection, otherwise False.
Example:
#python 3.4
From Os.path Import *
Pathstr = ' f:\\temp\\py\\cal_1.py '
R = Islink (PATHSTR)
Print (R)
The resulting output is as follows:
False
Os.path.ismount (PATH)
Determines if the path parameter is a mount point, if True is returned .
Example:
#python 3.4
From Os.path Import *
Pathstr = ' f:\\temp\\py\\cal_1.py '
R = Ismount (PATHSTR)
Print (R)
The resulting output is as follows:
False
Os.path.join (path1[, path2[, ...])
Properly connect directories and file composition paths.
Example:
#python 3.4
From Os.path Import *
Pathstr = ' f:\\temp\\py\\cal_1.py '
R = Join (' f:\\temp ', ' \\py\\cal_1.py ')
Print (R)
The resulting output is as follows:
F:\py\cal_1.py
Os.path.normcase (PATH)
Formats the path 's case and slash.
Example:
#python 3.4
From Os.path Import *
Pathstr = ' f:\\temp\\py\\cal_1.py '
R = Normcase (PATHSTR)
Print (R)
The resulting output is as follows:
f:\temp\py\cal_1.py
Os.path.normpath (PATH)
Remove the relative path from the path.
Example:
#python 3.4
From Os.path Import *
Pathstr = ' f:\\temp\\. \\py\\cal_1.py '
R = Normpath (PATHSTR)
Print (R)
The resulting output is as follows:
F:\py\cal_1.py
Os.path.realpath (PATH)
Returns the actual path, if the relative path is removed, if the shortcut returns the True path.
Example:
#python 3.4
From Os.path Import *
Pathstr = ' f:\\temp\\. \\py\\cal_1.py '
R = Realpath (PATHSTR)
Print (R)
The resulting output is as follows:
F:\py\cal_1.py
Os.path.relpath (Path, Start=os.curdir)
Converts the path to a relative path with the directory start as the standard.
Example:
#python 3.4
From Os.path Import *
Pathstr = ' f:\\temp\\. \\py\\cal_1.py '
R = RelPath (PATHSTR)
Print (R)
The resulting output is as follows:
.. \.. \.. \py\cal_1.py
Os.path.samefile (path1, path2)
Determine if two paths are the same. Returns Falseif the same returns True.
Example:
#python 3.4
From Os.path Import *
Pathstr = ' f:\\temp\\py\\cal_1.py '
R = RelPath (PATHSTR)
Print (R)
R = Samefile (Pathstr, R)
Print (R)
The resulting output is as follows:
.. \.. \py\cal_1.py
True
Os.path.sameopenfile (FP1, FP2)
Determine if FP1 and FP2 are the same file, if the same returns True, otherwise Falseis returned.
Example:
#python 3.4
From Os.path Import *
Pathstr = ' f:\\temp\\py\\cal_1.py '
R = RelPath (PATHSTR)
Print (R)
FP1 = open (PATHSTR)
FP2 = open (R)
R = Sameopenfile (Fp1.fileno (), Fp2.fileno ())
Print (R)
Fp1.close ()
Fp2.close ()
The resulting output is as follows:
.. \.. \py\cal_1.py
True
Os.path.samestat (STAT1, STAT2)
The file status is determined to determine whether two files point to the same file, and if true, returns False.
Example:
#python 3.4
From Os.path Import *
Import OS
Pathstr = ' f:\\temp\\py\\cal_1.py '
R = RelPath (PATHSTR)
Print (R)
FP1 = Os.stat (PATHSTR)
FP2 = Os.stat (r)
R = Samestat (FP1, FP2)
Print (R)
The resulting output is as follows:
.. \.. \py\cal_1.py
True
Os.path.split (PATH)
The path is divided into two parts: path and file name.
Example:
#python 3.4
From Os.path Import *
Import OS
Pathstr = ' f:\\temp\\py\\cal_1.py '
R = Split (PATHSTR)
Print (R)
The resulting output is as follows:
(' F:\\temp\\py ', ' cal_1.py ')
Os.path.splitdrive (PATH)
The path paths are decomposed into drive and relative to drive paths.
Example:
#python 3.4
From Os.path Import *
Import OS
Pathstr = ' f:\\temp\\py\\cal_1.py '
R = Split (PATHSTR)
Print (R)
R = splitdrive (PATHSTR)
Print (R)
The resulting output is as follows:
(' F:\\temp\\py ', ' cal_1.py ')
(' F: ', ' \\Temp\\py\\cal_1.py ')
Os.path.splitext (PATH)
The path paths are decomposed into file names and suffixes.
Example:
#python 3.4
From Os.path Import *
Import OS
Pathstr = ' f:\\temp\\py\\cal_1.py '
R = Split (PATHSTR)
Print (R)
R = splitdrive (PATHSTR)
Print (R)
R = Splitext (PATHSTR)
Print (R)
The resulting output is as follows:
(' F:\\temp\\py ', ' cal_1.py ')
(' F: ', ' \\Temp\\py\\cal_1.py ')
(' F:\\temp\\py\\cal_1 ', '. Py ')
Os.path.splitunc (PATH)
The path is decomposed as a UNC way.
Example:
#python 3.4
From Os.path Import *
Import OS
Pathstr = ' f:\\temp\\py\\cal_1.py '
R = Split (PATHSTR)
Print (R)
R = splitdrive (PATHSTR)
Print (R)
R = Splitext (PATHSTR)
Print (R)
R = Splitunc (PATHSTR)
Print (R)
R = Splitunc (R ' \\192.168.0.1\abc\test.py ')
Print (R)
The resulting output is as follows:
(' F:\\temp\\py ', ' cal_1.py ')
(' F: ', ' \\Temp\\py\\cal_1.py ')
(' F:\\temp\\py\\cal_1 ', '. Py ')
(', ' f:\\temp\\py\\cal_1.py ')
(' \\\\192.168.0.1\\abc ', ' \\test.py ')
Os.path.supports_unicode_filenames
Returns Trueif the Unicode string can be a file name ,otherwise False.
Example:
#python 3.4
From Os.path Import *
Import OS
Pathstr = ' f:\\temp\\py\\cal_1.py '
R = Split (PATHSTR)
Print (R)
Print (Supports_unicode_filenames)
The resulting output is as follows:
(' F:\\temp\\py ', ' cal_1.py ')
True
Cai Junsheng qq:9073204 Shenzhen
8.2 os.path--Common path name operation (1)