1, Os.path.splitext (path) #返回一个元祖 (path, extension)
For example:
>>> os.path.splitext ('/home/biotrainee/first/test.txt') (' /home/biotrainee/first/test ' ' . txt ')
and Os.path.split (path) is the return (path, filename. extension)
>>> os.path.split ('/home/biotrainee/first/test.txt') (' /home/biotrainee/first ' ' Test.txt ')
2. Os.path.dirname (path) returns the directory of the file path, which is the first element of Os.path.split (path), such as:
>>> os.path.dirname ('/home/biotrainee/first/test.txt') ' /home/biotrainee/first '
3, Os.path.basename (path) returns the last file name of path, which is the second element of Os.path.split (path), such as:
>>> os.path.basename ('/home/biotrainee/first/test.txt')' Test.txt '
4, os.path.exists (path) returns true if path exists, or false if path does not exist. Such as:
>>> os.path.exists ('/home/biotrainee/first/test.txt') False> >> os.path.exists ('/home/') True
5, Os.path.isabs (path) returns True if path is an absolute path. Such as:
>>> os.path.isabs ('/home/biotrainee/first/test.txt') True>> > Os.path.isabs ('.. /biotrainee/first/test.txt') False
Wait, wait.
Python Os.path Module