Posts

Showing posts from January, 2019

File Handling Using Python

Image
  Concept Operation 1: When we are trying to write on file by using Python we have 2 kinds of write mode. i) 'w' stands for write mode but in this mode, the old file will be deleted by new file ii) 'a' also stands for write mode but in this mode, new data will be appended with old file   Operation 2: When we are reading data from the file we will be using read mode 'r  Write # ['a', 'w'] f = open("demo.txt", 'a') data = input('Enter Some Data :') f.write(data) f.close() Read f = open("demo.txt", 'r') print(f.read())  [ --> Reading whole data ] print(f.readline())  [ --> Reading a single Line ] print(f.readlines())  [ --> Whole data will be devided by newline and convert it as a List] print(f.read(10))  [ --> Will read from postion to postion 10 from a file] f.close()   Quiz Level 1 Quiz Level 2 Request Me