-->
当前位置:首页 > 题库

PROGRAMMING:Enter a line of string and convert it to a decimal number for output

Luz5年前 (2021-05-10)题库352
Input a line of string, remove the non hexadecimal characters, and convert it to a decimal number output.
###Input format:
Enter a line of string.
###Output format:
Output hexadecimal string and converted decimal number.
###Input example:
Here is a set of inputs. For example:
```in
_ ahg1*B
```
###Output example:
The corresponding output is given here. For example:
```out
a1B
two thousand five hundred and eighty-seven
```







answer:If there is no answer, please comment
```
S = input () # first layer, input layer
#Second floor
lst=[t for t in s if ord('0')<=ord(t)<=ord('9')
or ord('a')<=ord(t)<=ord('f')
or ord('A')<=ord(t)<=ord('F')
]
#The third layer
news=''.join(lst)
#Layer 4 output layer
print(news)
print(int(news,16))
```