在Python中,可以通过以下两种方式调用函数:
hello
的函数,可以像下面这样调用它:def hello(name):
print("Hello, " + name)
hello("Alice")
greet
的函数,可以将该函数赋值给一个变量,然后通过该变量调用函数:def greet(name):
print("Nice to meet you, " + name)
my_func = greet
my_func("Bob")
无论哪种方式,都可以用来调用函数并执行其中定义的代码。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: python异或运算符的使用方法是什么