Spaces in python

ok I know this should be simple ... anyway:

line = "$W5M5A,100527,142500,730301c44892fd1c,2,686.5  4,333.96,0,0,28.6,123,75,-0.4,1.4*49"

I want to cut out the spaces. I thought you would just do it.

line = line.strip()

but now the string is still '$ W5M5A, 100527.1442500.730301c44892fd1c, 2,686.5 4,333,96,0,0,28,6,123,75, -0,4,1,4 * 49' instead of $ W5M5A, 100527,142500,730301c44892fd1c , 2,686,54,333,96,0,0,28,6,123,75, -0,4,1,4 * 49 '

any thoughts?

+3
source share
2 answers
line = line.replace(' ', '')
+10
source

another way to do it

line = ''.join(line.split())
0
source

Source: https://habr.com/ru/post/1747993/


All Articles