python print方法能否打印函數(shù)

小樊
81
2024-09-25 07:46:11

是的,Python的print()函數(shù)可以打印函數(shù)。你可以將函數(shù)名作為字符串傳遞給print()函數(shù),然后調(diào)用該函數(shù)。例如:

def my_function():
    print("Hello, world!")

print("Calling the function:")
my_function()

輸出:

Calling the function:
Hello, world!

0