我正在做作业,我需要把属性表中的高度字段转换成另一个字段中的CM。现在我有:
with arcpy.da.SearchCursor(position + ".shp", "height") as cursor:
for row in cursor: heightcm = row[0]
height = heightcm.split("' ")
feet = int(height[0])
inches = int(height[1])
cm = (12*feet + inches)* 2.54
print(cm) 我知道“5'11”的格式搞砸了我的分裂,但我不知道如何解决这个问题,有人能帮帮我吗?
我得到了一个带有10:‘1’的int()的ValueError:无效的文本
发布于 2022-02-08 01:19:15
要转化,你可以这样做
for row in cursor:
heightcm = row[0]
height = heightcm.split("'")
feet = int(height[0])
inches = int(height[1][:-2])
cm = (12*feet + inches)* 2.54
print(cm)https://stackoverflow.com/questions/71027421
复制相似问题