Function: Split ()
There are two functions for split () and Os.path.split () in Python, as follows:
Split (): Splits the string. Slices a string by specifying a delimiter and returns a segmented list of strings
Os.path.split (): Splits the file name and path by path
First, function description
1. Split () function
Syntax: Str.split (str= "", Num=string.count (str)) [n]
Parameter description:
STR: is represented as a delimiter, the default is a space, but cannot be empty ('). If there is no delimiter in the string, the entire string is used as an element of the list
Num: Indicates the number of splits. If there is a parameter num, it is separated into only num+1 substrings, and each substring can be assigned to a new variable
[n]: Indicates selection of Nth Shard
Note: When spaces are used as separators, items that are empty in the middle are automatically ignored
2. Os.path.split () function
Syntax: Os.path.split (' path ')
Parameter description:
1.PATH refers to the full path of a file as a parameter:
2. If a directory and file name is given, the output path and filename
3. If a directory name is given, the output path and the empty file name
The use of the split () function in Python