''' This code use python file read/write syntax ''' directory="C:/pythonFile.txt" ''' Open file in write mode ''' f=open(directory,'w') f.write("Life is easy with Python") f.close() ''' Open file for writeing data in binary format ''' f=open(directory,'wb') f.write("Life is easy with Python") f.close() ''' Open file in append mode ''' f=open(directory,'a') f.write("Life is easy with Python") f.close() ''' Read data from file ''' f=open(directory,'r') for line in f.readlines(): print line f.close()
Output:
Check "C:" drive
0 comments:
Post a Comment