Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

วิธีดึงชื่อ Function เป็น String ใน Python

ทุกฟังก์ชันมี attribute __name__

ตัวอย่าง

def some_func():
    return 0

print(some_func.__name__)

ผลลัพธ์

some_func