पायथन फ़ाइल पढ़ें () विधि
उदाहरण
"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))