有一个3位数,请逆序输出它的各位数字的Python代码
时间: 2023-05-21 10:06:14 浏览: 80
python 给一个不多于5位的正整数,要求:一、求它是几位数,二、逆序打印出各位数字 (示例)
5星 · 资源好评率100%
Sure, here's the Python code to reverse the digits of a 3-digit number:
```
num = 123 # Replace with your desired 3-digit number
rev_num = int(str(num)[::-1])
print(rev_num)
```
This code first converts the input number (`num`) to a string, reverses it (`[::-1]`), and then converts it back to an integer. Finally, it prints the reversed number (`rev_num`).
阅读全文