python - using the .split method -


my question after using .split() method, how python know start split?

for example if have opened txt file using python , decide use line split method this;

user = line.split(':')[0] john: hhwoeioawn: 802:0933:iama john:/home/john:/bin/sh 

as can see, (":") occurs more once.

as said, question isn't absolutely clear. looking @ code, seems want first word returned split, in case, may use like:

user = line[:line.index(":")] 

best regards.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -