标签:code == number col int 求和 数字 coding input
# -*- coding: utf-8 -*- """ Created on Sun Apr 22 16:27:35 2018 @author: MyPC """ def main(): ‘‘‘ 对一个整数中的各个数字求和. input:number output:sum ‘‘‘ numbere_str = input("input nummber :") number =eval(numbere_str) number_len = len(numbere_str) sum = 0 for i in range(1,number_len+1): digit = number % 10 number = number // 10 sum += digit print("The sum of the digit is %d :"%(sum)) if __name__ == "__main__": main()
标签:code == number col int 求和 数字 coding input
原文地址:https://www.cnblogs.com/Wang-Y/p/8908308.html