how can we convert a string [0.0034596999, 0.0034775001, 0.0010091923]
to a form [0.0034596999 0.0034775001 0.0010091923]
in python. I tried using map
, join
etc functions but I am unable to do so. Can anyone help?
Using the string method replace()
is an efficient solution; however thought I'd offer an alternate using split()
and join()
:
print ''.join(i for i in '[0.0034596999, 0.0034775001, 0.0010091923]'.split(','))
>>> [0.0034596999 0.0034775001 0.0010091923]
"[0.0034596999, 0.0034775001, 0.0010091923]".replace(",", "")
returns "[0.0034596999 0.0034775001 0.0010091923]"
Have a look at the string methods - there are many useful ones.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With