n=input("请输入任意一个自然数:")print(sum(map(int,n)))
input得到的是字符串n="-2",字符串作为可迭代的对象。map(int,n)对没每个字符进行int转换。“-”进行int转换会生成错误的。