求100-999之间所有的水仙花数

#求100-999之间所有的水仙花数 例:153=1^3+5^3+3^3
for num in range(100,1000):
    hundredp=int(num/100)
    tenp=int((num%100)/10)
    digitp=(num%100)%10
    if num==(hundredp**3)+(tenp**3)+(digitp**3):
        print(num)    
#方法二
for i in range(100, 1000):
    sum = 0
    temp = i
    while temp:
        sum = sum + (temp%10) ** 3
        temp //= 10         # 注意这里要使用地板除哦~
    if sum == i:
        print(i)
原文地址:https://www.cnblogs.com/themost/p/6358872.html