import re
def cheng ( n) :
result= 1
jinzhi= [ 1 , 2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 ]
for i in range ( 0 , len ( jinzhi) ) :
if ( n== jinzhi[ i] ) :
for j in range ( 0 , i+ 1 ) :
result*= jinzhi[ j]
return result
def main ( ) :
while ( True ) :
num= input ( "请输入十位以下的火星码:" )
n= [ ]
zzs= ''
sum = 0
count= 0
for i in range ( 0 , len ( num) ) :
n. append( num[ i] )
if ( len ( n) >= 10 ) :
continue
elif ( len ( n) < 10 ) :
zhengze= [ '[0-9a-jA-J]{0,1}' , '[0-9a-iA-I]{0,1}' , '[0-9a-dA-D]{0,1}' , '[0-9a-bA-B]{0,1}' , '[0-7]{0,1}' , '[0-5]{0,1}' , '[0-3]{0,1}' , '[0-2]{0,1}' , '[0-1]{0,1}' ]
for j in range ( 0 , len ( n) ) :
if ( re. search( num[ len ( n) - 1 - j] , zhengze[ 8 - j] ) ) :
count+= 1
if ( count== len ( n) ) :
n. reverse( )
jinzhi= [ 1 , 2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 ]
for i in range ( 0 , len ( n) ) :
sum += int ( n[ i] ) * cheng( int ( jinzhi[ i] ) )
print ( "该火星码对应的十进制值为" , sum )
return 0
else :
continue
if __name__ == '__main__' :
main( )