我正在尝试将数字(最多30个)转换为罗马数字。使用另一个字段计算器函数的脚本作为模板,我创建了这个不想工作的脚本。任何帮助将不胜感激!
def NumberToRomanNumeral ( !CONCESSION! ):
if CONCESSION == "1":
newstr = "I"
elif CONCESSION == 2:
newstr = "II"
elif CONCESSION == 3:
newstr = "III"
elif CONCESSION == 4:
newstr = "IV"
elif CONCESSION == 5:
newstr = "V"
elif CONCESSION == 6:
newstr = "VI"
elif CONCESSION == 7:
newstr = "VII"
elif CONCESSION == 8:
newstr = "VIII"
elif CONCESSION == 9:
newstr = "IX"
elif CONCESSION == 10:
newstr = "X"
elif CONCESSION == 11:
newstr = "XI"
elif CONCESSION == 12:
newstr = "XII"
elif CONCESSION == 13:
newstr = "XIII"
elif CONCESSION == 14:
newstr = "XIV"
elif CONCESSION == 15:
newstr = "XV"
elif CONCESSION == 16:
newstr = "XVI"
elif CONCESSION == 17:
newstr = "XVII"
elif CONCESSION == 18:
newstr = "XVIII"
elif CONCESSION == 19:
newstr = "XIX"
elif CONCESSION == 20:
newstr = "XX"
elif CONCESSION == 21:
newstr = "XXI"
elif CONCESSION == 22:
newstr = "XXII"
elif CONCESSION == 23:
newstr = "XXIII"
elif CONCESSION == 24:
newstr = "XXIV"
elif CONCESSION == 25:
newstr = "XXV"
elif CONCESSION == 26:
newstr = "XXVI"
elif CONCESSION == 27:
newstr = "XXVII"
elif CONCESSION == 28:
newstr = "XXVIII"
elif CONCESSION == 29:
newstr = "XXIX"
elif CONCESSION == 30:
newstr = "XXX"
else:
newstr = ""
return newstr
答案 0 :(得分:1)
感叹号位置错误 - 应该是
表达:
NumberToRomanNumeral(!CONCESSION!)
代码阻止:开始...
def NumberToRomanNumeral(CONCESSION):