在这个Python函数中,最后一行代表什么?

2024-04-27 01:06:01 发布

您现在位置:Python中文网/ 问答频道 /正文

def f(x):
    xs=str(x)
    if len(xs) == 1:
        return int(xs)
    n = int(xs[0]) + int (xs[1])
    if len (xs) == 2:
        return n
    else:
        return n+f(xs[2:])

具体来说,f(xs[2:])做什么?你知道吗


Tags: lenreturnifdefelseintxsstr