Q. What is the difference between the following set of statements (a) and (b):
a) P = open("practice.txt","r")
P.read(10)
b) with open("practice.txt", "r") as P:
x = P.read()
Answer :-
In part "a" file P will read 10 characters but will not print anythings while in part "b" it will read whole character present in practice file and store in variale "x".
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )