partition string in python and get value of last segment after colon
Solution 1:
result = mystring.rpartition(':')[2]
If you string does not have any :
, the result will contain the original string.
An alternative that is supposed to be a little bit slower is:
result = mystring.split(':')[-1]
Solution 2:
foo = "client:user:username:type:1234567"
last = foo.split(':')[-1]
Solution 3:
Use this:
"client:user:username:type:1234567".split(":")[-1]