输入一个四位数 通过数字类型的基本操作,获取个十百千位的数字,并生成一个新的四位数 是输入的四位数的倒序
num = int(input())
info = "个十百千"
if num>=1001:
x = num
x_lst = [0,0,0,0]
for i in range(len(x_lst)):
x_lst[i] = x % 10
x = (x - x_lst[i])//10
print(info[i],x_lst[i],end = "\t")
print("")
print("".join([str(n) for n in x_lst]))
else:
print("请输入4位数")
def func(n: int):
n1 = int(n / 10 ** 0) % 10 # 取个位数上数字
n2 = int(n / 10 ** 1) % 10 # 取十位数上数字
n3 = int(n / 10 ** 2) % 10 # 取百位数上数字
n4 = int(n / 10 ** 3) % 10 # 取千位数上数字
return n1 * 10 ** 3 + n2 * 10 ** 2 + n3 * 10 ** 1 + n4 * 10 ** 0 # 组合数字