問題:
I want to take the string 0.71331, 52.25378
and return 0.71331,52.25378
- ie just look for a digit, a comma, a space and a digit, and strip out the space.我想取字符串0.71331, 52.25378
並返回0.71331,52.25378
- 即只查找一個數字、一個逗號、一個空格和一個數字,然後0.71331,52.25378
空格。
This is my current code:這是我當前的代碼:
coords = '0.71331, 52.25378'
coord_re = re.sub("(\d), (\d)", "\1,\2", coords)
print coord_re
But this gives me 0.7133,2.25378
.但這給了我0.7133,2.25378
。 What am I doing wrong?我究竟做錯了什麼?