Python delattr() လုပ်ဆောင်ချက်
ဥပမာ
"လူ" အရာဝတ္ထုမှ "အသက်" ပိုင်ဆိုင်မှုကိုဖျက်ပါ-
class Person:
name = "John"
age = 36
country = "Norway"
delattr(Person, 'age')
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
လုပ်ဆောင်ချက် သည် delattr()
သတ်မှတ်ထားသော အရာဝတ္ထုမှ သတ်မှတ်ထားသော အရည်အချင်းကို ဖျက်ပစ်မည်ဖြစ်သည်။
အထားအသို
delattr(object, attribute)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
object | Required. An object. |
attribute | Required. The name of the attribute you want to remove |
ဆက်စပ်စာမျက်နှာများ
attribute တစ်ခု၏ တန်ဖိုးကိုရယူရန် getattr() လုပ်ဆောင်ချက်
attribute တစ်ခုရှိ၊ မရှိ စစ်ဆေးရန် hasattr() လုပ်ဆောင်ချက်
attribute တစ်ခု၏ တန်ဖိုးကိုသတ်မှတ်ရန် setattr() လုပ်ဆောင်ချက်