ArcGIS Pro VB和python二分式
'设计人:闫磊 Function spacenum(n) str="" For i=0 To n str=str+"_" Next spacenum=str End Function '----------FUNCTION STRLEN(STR)---------- Function strlen(str) Dim p_len p_len=0 strlen=0 p_len=Len(str) For xx=1 To p_len If Asc(Mid(str,xx,1))<0 Then strlen=Int(strlen) + 2 Else strlen=Int(strlen) + 1 End If Next End Function Function myFind ( DZM, NAME ) a=strlen(dzm) b=strlen(NAME) If a>b Then myFind ="<und>" & DZM & "</und>" & vbnewline & NAME Else str= Spacenum((b-a)/2) myFind ="<und>" & str & DZM & str & "</und>" & vbnewline & NAME End If End Function '编制日期:2012-03-25 Function FindLabel ( [TFH],[Shape_Area]) FindLabel =myFind([Shape_Area],[TFH]) End Function
def spacenum(s, d): ss = s if d>1: for i in range(0, d - 1): ss = ss + s return ss def strlen(str): n = 0 for s in str: if s.isalpha(): n = n + 2 else: n = n + 1 return n def myLabel(fz, fm, f3): str1 = strlen(f3) d = strlen(f3) d1 = int(strlen(fz) / 2) d2 = int(strlen(fm) / 2) if d2 > d1: d1 = d2 return fz + spacenum(" ", d) + "\n" + spacenum("—", d1) + f3 + "\n" + fm + spacenum(" ", d) def FindLabel([省], [省代码], [shape_area]): return myLabel([省], str([省代码]), str([shape_area]))