看晕了……求解……
程序代码:
# Returning functions from functions # A simple function def say_hello(greeter, greeted): return "Hello, " + greeted + ", I'm " + greeter + "." # We can use it like this: print say_hello("Alice", "Bob") # Displays "Hello, Bob, I'm Alice." # We can also use it in a function: def produce_greeting_from_alice(greeted): return say_hello("Alice", greeted) print produce_greeting_from_alice("Bob") # Displays "Hello, Bob, I'm Alice." # We can also return a function from a function by nesting them: def produce_greeting_from(greeter): def greet(greeted): return say_hello(greeter, greeted) return greet # Here we create a greeting function for Eve: produce_greeting_from_eve = produce_greeting_from("Eve")//这里能理解为C中#define produce_greeting_from_eve produce_greeting_from("Eve") 么? # 'produce_greeting_from_eve' is now a function: print produce_greeting_from_eve("Alice") # Displays "Hello, Alice, I'm Eve." # You can also invoke the function directly if you want: print produce_greeting_from("Bob")("Eve") # Displays "Hello, Eve, I'm Bob."