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

วิธี Look Inside Python Object

Python มี Built-in Functions ชุดแข็งแกร่งต่อไปนี้เพื่อรวบรวมข้อมูลเกี่ยวกับ Attributes, Properties และ Methods ของ Python Object ใดๆ -

  • type()
  • dir()
  • id()
  • getattr()
  • hasattr()
  • globals()
  • locals()
  • callable()

type() และ dir() มีประโยชน์โดยเฉพาะสำหรับการหา Type ของ Object และ Set ของ Attributes ตามลำดับ