Python中的函式可以作為一個變數去參考,
根據這樣的特性,可以更好認識Python中,一切皆物件的思想,一切皆地址,
# coding=utf-8
def power(base, exponent):
result = 1
for i in range(1, exponent + 1):
result *= base
return result
a = power
print(id(a))
print(id(power))
print(a(2, 3))
# python3.6 001將函式作為變數去使用.py
4339142168
4339142168
8
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/59860.html
標籤:Python
