leetcode1271

 1 class Solution:
 2     def toHexspeak(self, num: str) -> str:
 3         dic = {'a':'A','b':'B','c':'C','d':'D','e':'E','f':'F',' . 1 ' : ' the I ' , ' 0 ' : ' O ' }
 . 4          dn_10 = int (NUM)
 . 5          dn_16 = hex (dn_10) hex # 10 revolutions hexadecimal
 . 6          str_16 = STR (dn_16) [ 2 :] # minus the prefix 0x
 . 7          R & lt = '' 
. 8          for I in Range (len (str_16)):
 . 9              IF str_16 [I] in DIC:
 10                  R & lt + = DIC [str_16 [I]]
 . 11              the else :
 12 is                 return 'ERROR'
13         return r

 

Guess you like

Origin www.cnblogs.com/asenyang/p/11965104.html