-5

How to split the string here I having this format

position:absolute;top:188.97638px;left:642.519692px;font-size:10.0px;font-family:Ubuntu Mono;width:25%;float:left

. I need like this

position:absolute;
top:188.97638px;
left:642.519692px;
font-size:10.0px;
font-family:Ubuntu Mono;
width:25%;
float:left

How to get this.

1 Answers1

1

Try this:

>>> mystring = "position:absolute;top:188.97638px;left:642.519692px;font-size:10.0px;font-family:Ubuntu Mono;width:25%;float:left"
>>> result = [x + ";" for x in mystring.split(";")]                             
>>> print '\n'.join(result)

Output:

position:absolute;
top:188.97638px;
left:642.519692px;
font-size:10.0px;
font-family:Ubuntu Mono;
width:25%;
float:left;

If you really have to get rid of the last part's semi colon:

result[-1] = result[-1][:-1]
Reut Sharabani
  • 30,449
  • 6
  • 70
  • 88