Cs ch5 File Handelling
Cs ch5 File Handelling
Cs ch5 File Handelling
Sol: L=[1,3,5,7,9,11]
F1=open(“stud1.txt”,”w”)
F1.writelines(str(L))
F1.close()
With statement: It ensures that all resources allocated
to the file objects get de-allocated automatically. No
need to use close() function.
Syntax:
#Program to use “with” statements
Sol: with open(“abc.txt”,”w”) as f:
f.write(“India is my country”)
*Standard INPUT ,OUTPUT and ERROR streams:-
>>>import sys
Standard input device:-stdin
Standard output device:-stdout
Standard error device:-stderr