将坐标中的值分为横纵坐标数组x与y:(-2.0, 1.9800000000000035) (-1.99, 1.9800000000000035) (-1.98, 1.9800000000000035) (-1.97, 1.9800000000000035) (-1.96, 1.9800000000000035) (-1.95, 1.9800000000000035) (-1.94, 1.9800000000000035) (-1.93, 1.9800000000000035) (-1.92, 1.9800000000000035) (-1.91, 1.9800000000000035) (-1.9, 1.9800000000000035) (-1.89, 1.9800000000000035) (-1.88, 1.9800000000000035) (-1.8699999999999999, 1.9800000000000035) (-1.8599999999999999, 1.9800000000000035) (-1.8499999999999999, 1.9800000000000035) (-1.8399999999999999, 1.9800000000000035) (-1.8299999999999998, 1.9800000000000035) (-1.8199999999999998, 1.9800000000000035) (-1.8099999999999998, 1.9800000000000035) (-1.7999999999999998, 1.9800000000000035) (-1.7899999999999998, 1.9800000000000035) (-1.7799999999999998, 1.9800000000000035) (-1.7699999999999998, 1.9800000000000035) (-1.7599999999999998, 1.9800000000000035) (-1.7499999999999998, 1.9800000000000035) (-1.7399999999999998, 1.9800000000000035) (-1.7299999999999998, 1.9800000000000035)
时间: 2023-08-05 13:07:40 浏览: 457
可以使用Python的列表切片来将给定的坐标字符串转换为横纵坐标数组。具体操作如下:
```python
coordinates = [(-2.0, 1.9800000000000035), (-1.99, 1.9800000000000035), (-1.98, 1.9800000000000035), (-1.97, 1.9800000000000035), (-1.96, 1.9800000000000035), (-1.95, 1.9800000000000035), (-1.94, 1.9800000000000035), (-1.93, 1.9800000000000035), (-1.92, 1.9800000000000035), (-1.91, 1.9800000000000035), (-1.9, 1.9800000000000035), (-1.89, 1.9800000000000035), (-1.88, 1.9800000000000035), (-1.8699999999999999, 1.9800000000000035), (-1.8599999999999999, 1.9800000000000035), (-1.8499999999999999, 1.9800000000000035), (-1.8399999999999999, 1.9800000000000035), (-1.8299999999999998, 1.9800000000000035), (-1.8199999999999998, 1.9800000000000035), (-1.8099999999999998, 1.9800000000000035), (-1.7999999999999998, 1.9800000000000035), (-1.7899999999999998, 1.9800000000000035), (-1.7799999999999998, 1.9800000000000035), (-1.7699999999999998, 1.9800000000000035), (-1.7599999999999998, 1.9800000000000035), (-1.7499999999999998, 1.9800000000000035), (-1.7399999999999998, 1.9800000000000035), (-1.7299999999999998, 1.9800000000000035)]
x = [coord[0] for coord in coordinates]
y = [coord[1] for coord in coordinates]
print(x)
print(y)
```
输出结果为:
```
[-2.0, -1.99, -1.98, -1.97, -1.96, -1.95, -1.94, -1.93, -1.92, -1.91, -1.9, -1.89, -1.88, -1.8699999999999999, -1.8599999999999999, -1.8499999999999999, -1.8399999999999999, -1.8299999999999998, -1.8199999999999998, -1.8099999999999998, -1.7999999999999998, -1.7899999999999998, -1.7799999999999998, -1.7699999999999998, -1.7599999999999998, -1.7499999999999998, -1.7399999999999998, -1.7299999999999998]
[1.9800000000000035, 1.9800000000000035, 1.9800000000000035, 1.9800000000000035, 1.9800000000000035, 1.9800000000000035, 1.9800000000000035, 1.9800000000000035, 1.9800000000000035, 1.9800000000000035, 1.9800000000000035, 1.9800000000000035, 1.9800000000000035, 1.9800000000000035, 1.9800000000000035, 1.9800000000000035, 1.9800000000000035, 1.9800000000000035, 1.9800000000000035, 1.9800000000000035, 1.9800000000000035, 1.9800000000000035, 1.9800000000000035, 1.9800000000000035, 1.9800000000000035, 1.9800000000000035, 1.9800000000000035, 1.9800000000000035]
```
其中,变量 `x` 和 `y` 分别为横坐标数组和纵坐标数组。
阅读全文