一种选择是将coordinates
方括号括起来并使用literal_eval()
:
>>> from ast import literal_eval >>> coordinates = "(-89.38477, 26.6671), (-89.38477, 27.13737), (-88.81348, 27.13737), (-88.81348, 26.6671)" >>> >>> data = list(literal_eval(coordinates)) >>> data [(-89.38477, 26.6671), (-89.38477, 27.13737), (-88.81348, 27.13737), (-88.81348, 26.6671)]