python - Python Script to find lowest coordinates in a list
问题描述
I have a list containing coordinates in the order of Y,X,Z. I am trying to use python to find the coordinates for lowest Z value. The list contains 4 sets of coordinates separated by space. Part of the code I am using is below.
<gml:coordList>200.0001 400.0001 30.0001 210.0002 410.0002 31.0002 190.0003 401.0003 29.0003 213.0004 402.0004 38.0004</gml:coordList>
y1,x1,z1,y2,x2,z2,y3,x3,z3,y4,x4,z4 = coordList[0:-1].split(' ')
list1 = []
list1.append((z1,y1,x1))
list1.append((z2,y2,x2))
list1.append((z3,y3,x3))
list1.append((z4,y4,x4))
minz = min((list1))
x, y, z = minz[0:-1].split(' ')
The error I am getting is this : AttributeError: 'tuple' object has no attribute 'split'
May I know why I am getting error and if there is a better way to achieve my goal?
Thank you
解决方案
If minz
is already a tuple type, you can assign x
,y
,z
to each tuple value.
z, y, x = minz
推荐阅读
- python - 为什么我的合并排序程序不起作用?
- amazon-web-services - CodeDeploy 与私有子网实例上的 VPC 终端节点
- python - Pytest 安排测试组之间的时间间隔
- javascript - 进度条不适用于我的 JavaScript 代码
- python - Python 用另一个 dict 扩展 __dict__ 对象
- android - 在android studio的后台15分钟后更新用户位置
- collections - 纽曼集合变量
- kubernetes - 带有 Keycloak 网关守卫边车的 Knative 服务
- arrays - 重击。预设变量
- yocto - 是否可以对 yocto 食谱上的源文件进行更改并生效?