SarkariResultess QA Bank

Python में text file read करने का सही तरीका क्या है? — interview में इसका सही जवाब क्या है?

Other 0 Views Verified
Python में text file read करने का सही तरीका क्या है? — interview में इसका सही जवाब क्या है?
Sarkari Result QA Bank
Editorially reviewed exam information

Answer & Explanation

4 Answers
Verified

file.read('data.txt')

file.read('data.txt')
Additional Explanation
यह विकल्प सही समाधान नहीं है।
Verified

open_file('data.txt')

open_file('data.txt')
Additional Explanation
यह विकल्प सही समाधान नहीं है।
Verified Correct Answer

with open('data.txt', 'r', encoding='utf-8') as f: text = f.read()

with open('data.txt', 'r', encoding='utf-8') as f: text = f.read()
Additional Explanation
with open context manager file को safely close करता है।
Verified

with file('data.txt'):

with file('data.txt'):
Additional Explanation
यह विकल्प सही समाधान नहीं है।