line.split()
时间: 2024-02-10 08:38:09 浏览: 70
python字符串切割:str.split()与re.split()的对比分析
The `split()` method is a built-in function in Python that is used to split a string into a list of substrings based on a specified delimiter.
When called on a string variable named `line`, the `split()` method will split the string into substrings separated by whitespace (spaces, tabs, and newlines) by default. The resulting substrings will be returned as a list.
Example:
```
line = "The quick brown fox"
words = line.split()
print(words)
```
Output:
```
['The', 'quick', 'brown', 'fox']
```
In this example, the `split()` method is called on the string variable `line`, which contains the sentence "The quick brown fox". Since no delimiter is specified, the method splits the string into a list of words, which are stored in the `words` variable. The resulting list contains the words "The", "quick", "brown", and "fox".
阅读全文