os module ရှိ path.isfile method
path.isfile method သည် parameter တွင်ဖော်ပြထားသော
ဖိုင်ရှိ/မရှိ စစ်ဆေးပေးသည်။
ထို့အပြင် ဤ method ကို parameter တွင်ဖော်ပြထားသော path သည်
ဖိုင်တစ်ခုဟုတ်/မဟုတ် ဆုံးဖြတ်ရန်လည်း အသုံးပြုနိုင်ပါသည်။ Method သည်
boolean တန်ဖိုးပြန်ပေးသည်- အကယ်၍ path သည် ဖိုင်တစ်ခုဖြစ်ပါက
True ပြန်ပေးပြီး၊ မဟုတ်ပါက False ပြန်ပေးသည်။
ဖွဲ့စည်းပုံ
import os
print(os.path.isfile(လမ်းကြောင်း))
ဥပမာ
ပေးထားသော လမ်းကြောင်းသည် ဖိုင်တစ်ခုဟုတ်/မဟုတ် ထပ်မံစစ်ဆေးကြည့်ရအောင်-
import os
print(os.path.isfile('file.txt'))
ကုဒ်အလုပ်လုပ်ပြီးနောက် ရလဒ်-
True
ဥပမာ
ယခု ပေးထားသော လမ်းကြောင်းသည် ဖိုင်တစ်ခုဟုတ်/မဟုတ် စစ်ဆေးကြည့်ရအောင်-
import os
print(os.path.isfile('dir'))
ကုဒ်အလုပ်လုပ်ပြီးနောက် ရလဒ်-
False
ဤအကြောင်းအရာများကိုလည်း ကြည့်ရှုပါ
-
path.isdirmethod ofosmodule,
which checks the existence of a folder -
path.existsmethod ofosmodule,
which checks the existence of a path -
copy2method ofshutilmodule,
which copies a file with metadata -
renamemethod ofosmodule,
which renames a file and folder -
path.joinmethod ofosmodule,
which joins paths -
path.getsizemethod ofosmodule,
which returns the size of a path in bytes