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
Post a Comment