>>> hello = open('hello.txt','w+')
>>> data = 'Indonesia is a nice one and what we hope here is like this one'
>>> hello.write(data)
>>> hello.close();
To read a file, use:
>>> hello = open('hello.txt', 'r+')
>>> data = hello.read() # read all file
>>> data = hello.readlines() # read all file
>>> data = hello.readline() # just read one line
No comments:
Post a Comment