두 변수 (geom1, geom2)에 대한 스 니펫 코드를 작성했지만 알지 못하는 경우 (geo1, geom2) 스 니펫 코드를 썼습니다. 변수 이름과 값을 반복하는 방법.python에서 변수 이름을 반복하고 값을 설정하는 방법은 무엇입니까?
import arcpy
# Spatial reference of input feature class
SR = arcpy.SpatialReference(4326)
InFc=r"D:\_GIS\VerticesToLine.gdb\Line"
output = r"D:\_GIS\VerticesToLine.gdb\test"
geom = [row[0] for row in arcpy.da.SearchCursor(InFc, ["[email protected]"])]
geom[0].union(geom[1])
g= geom[2].union(geom[0])
with arcpy.da.InsertCursor(output, ["[email protected]"]) as cur:
cur.insertRow((g,))
당신은'eval'를 사용할 수 있지만,이 나쁜 연습 간주 : 당신이 함께 recodrs의 임의의 수를
union
하려면, 당신은 할 수 있습니다. Patrick이 제안한 것처럼 목록을 사용하십시오. –