以下是我解决问题的方法。我认为之前的答案使用的正则表达式可能会慢一点(需要进行基准测试)。data = ["33.0595° N", "101.0528° W"]def convert(coord): val, direction = coord.split(" ") # split the direction and the value val = float(val[:-1]) # turn the value (without the degree symbol) into float return val if direction not in ["W", "S"] else -1 * val # return val if the direction is not Westconverted = [convert(coord) for coord in data] # [33.0595, -101.0528]