效果演示:

Python
def string_len(src):
return len(src.encode("gbk"))
def fix_len(src):
if src % 2 == 1:
return src + 1
else:
return src
def FindLabel ( [ZLDWMC], [DLBM], [DLMC], [Shape_Area] ):
# 把[Shape_Area]的平方米转换成公顷
area_hm = format(round(float([Shape_Area])/10000*15,2),'.2f') + "亩"
# 把[Shape_Area]的平方米转换成亩
area_mu = format(round(float([Shape_Area])/10000,4),'.4f')+"公顷"
new_line = "\n"
# 分割符号
hs = "—"
vs = "|"
center = "┼"
# 修改这部分内容控着标注文字
# 左上
top_left = [ZLDWMC]
# 右上
top_right = area_hm
# 左下
bottom_left = [DLBM]
# 右下
bottom_right = [DLMC]
max_len1=fix_len(max(string_len(top_left),string_len(bottom_left)))
max_len2=fix_len(max(string_len(top_right),string_len(bottom_right)))
return (max_len1 - string_len(top_left)) * " " + top_left + vs + top_right +(max_len2 - string_len(top_right)) * " " + new_line + int(max_len1 / 2) * hs + center + int(max_len2 / 2) * hs + new_line + (max_len1 - string_len(bottom_left)) * " " + bottom_left + vs + bottom_right +(max_len2 - string_len(bottom_right)) * " "
ArcGIS Pro标注设置:




说明:字体推荐使用Sarasa Gothic (更纱黑体)中的SarasaMonoSC-Regular (等距更纱黑体SC),因为只有等距更纱黑体的英文、数字宽度正好等于0.5个汉字,这样才能做到标注完全对齐。
更纱黑体下载地址:
① https://github.com/be5invis/Sarasa-Gothic/releases/download/v1.0.6b/SarasaMonoSC-TTF-1.0.6.zip