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