有一个3位数,请逆序输出它的各位数字的Python代码
时间: 2023-05-21 12:06:14 浏览: 81
把三位数逆序输出
3星 · 编辑精心推荐
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`).
阅读全文