函数可以作为参数传递给其他函数:
因为函数是对象,我们可以将它们作为参数传递给其他函数。可以接受其他函数作为参数的函数也称为高阶函数。在下面的示例中,我们创建了一个函数greet,它将函数作为参数。
# Python program to illustrate functions
# can be passed as arguments to other functions
def shout(text):
return text.upper()
def whisper(text):
return text.lower()
def greet(func):
# storing the function in a variable
greeting = func("Hi, I am created by a function passed as an argument.")
print greeting
greet(shout)
greet(whisper)
想用python的mark功能更改字号大小,但是输入###以后并没有变成标题大字,而是前面多了###,直接显示出来了,如图想问怎么才能在python里面使用MARK功能的时候更改字体大小