一、split()
#!/usr/bin/python
str = "I go to work";
x=str.split()
print (x);
运行结果如下所示
二、split中带有参数
2.1 参数num=1
#!/usr/bin/python
str = "I go to work";
x=str.split(' ', 1)
print (x);
运行结果如下所示
2.2 参数num=2
#!/usr/bin/python
str = "I go to work";
x=str.split(' ', 2)
print (x);
运行结果如下所示
2.3 参数num=3
#!/usr/bin/python
str = "I go to work";
x=str.split(' ', 3)
print (x);
运行结果如下所示