python 如何将负数转换为正数

def absolute(x):
    if x >= 0:
        return x
    else:
        return -x

print(absolute(3))
print(absolute(-119))

 

posted @ 2022-10-30 17:58  博无止境  阅读(86)  评论(0编辑  收藏  举报