Python File read() နည်းလမ်း
ဥပမာ
"demofile.txt" ဖိုင်၏အကြောင်းအရာကိုဖတ်ပါ-
f = open("demofile.txt", "r")
print(f.read())
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
read()
နည်းလမ်းသည် ဖိုင်မှ သတ်မှတ်ထားသော ဘိုက်အရေအတွက်ကို ပြန်ပေးသည် ။ မူရင်းမှာ -1 ဖြစ်ပြီး ဖိုင်တစ်ခုလုံးကို ဆိုလိုသည်။
အထားအသို
file.read()
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
size | Optional. The number of bytes to return. Default -1, which means the whole file. |
နောက်ထပ် ဥပမာများ
ဥပမာ
"demofile.txt" ဖိုင်၏အကြောင်းအရာကိုဖတ်ပါ-
f = open("demofile.txt", "r")
print(f.read(33))