To write to files you use
the write method, which writes a string to the file.
The best way to learn new things is to take a practical approach of the things you want to learn. Here is a fragment of code that demonstrates the use of the write statement in Python:
Æ’ python command
peoms = open('peomdata.txt', 'w')
peoms.write('Just a perfect day. Feed
animals in the zoo. Then later a movie, too...')
peoms.close()
with open("peomdata.txt")
as i:
print(i.read())
peoms = open('peomdata.txt', 'r')
print(peoms.read())
peoms.close()
√ output
Just a perfect day. Feed animals in
the zoo. Then later a movie, too...
Just a perfect day. Feed animals in
the zoo. Then later a movie, too...
Sign up here with your email

ConversionConversion EmoticonEmoticon