參考:https://steam.oxxostudio.tw/category/python/example/roman.html
def roman_to_num(a):
table = {'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000}
str2 = [i for i in a]
sum1 = 0
for i in range(len(str2)):
str2[i] = int(table[str2[i]])
str2.reverse()
sum1 = str2[0]
for i in range(1, len(str2)):
if str2[i] < str2[i-1]:
sum1 = sum1 - str2[i]
else:
sum1 = sum1 + str2[i]
return sum1
比較麻煩應該是這段