Get String Before And After Character Then Set Them As a Variable Python -


if want 2 string separated character set them variable how go doing that?

an example:

john:doe 

i want set "john" variable fname, , "doe" variable lname. want outcome of script following:

    print  fname     john     print lname     doe 

all appreciated. thanks!

split string : , unpack results:

>>> s = "john:doe" >>> s.split(':') ['john', 'doe'] >>> fname, lname = s.split(':') >>> fname 'john' >>> lname 'doe' 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -