>>> ts = "root 16788 0.0 0.1 4944 892 pts/1 R+ 11:57 0:00 ps xua"
>>> ts
'root 16788 0.0 0.1 4944 892 pts/1 R+ 11:57 0:00 ps xua'
>>> ts.split()
['root', '16788', '0.0', '0.1', '4944', '892', 'pts/1', 'R+', '11:57', '0:00', 'ps', 'xua']
>>> ts.split(" ",1)
['root', ' 16788 0.0 0.1 4944 892 pts/1 R+ 11:57 0:00 ps xua']
>>> tf = ts.split(" ",1)
>>> tf[0:1]
['root']
>>> tf[0:]
['root', ' 16788 0.0 0.1 4944 892 pts/1 R+ 11:57 0:00 ps xua']
>>> tf[:1]
['root']
>>> tf[1:]
[' 16788 0.0 0.1 4944 892 pts/1 R+ 11:57 0:00 ps xua']
转载于:https://blog.51cto.com/shiweifei/1700766