📜  python 数字总和 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:44.241000             🧑  作者: Mango

代码示例4
number = 123 # the number you want to sum the digits of

sum_of_digits = sum(int(digit) for digit in str(number))

print(sum_of_digits)