这篇文章已经发布超过一年了,内容可能已经过时,请谨慎参考。

新建方法

定义函数

使用 def 定义函数,未显式 return 时默认返回 None

def add(a, b):
    return a + b

result = add(1, 2)