Learn how to code with python: Lesson 4 - Reading and writing files

One of the most useful things to know how to do when just learning how to program is knowing how to read and write text files. In this video, I show you how to do just that.

Example code from the video:

>>> f = open('Desktop/lorumipsum.txt')
>>> print(f)
<_io.TextIOWrapper name='Desktop/lorumipsum.txt' mode='r' encoding='UTF-8'>
>>> f.readline()
'Lorem ipsum dolor sit amet,....

>>> f.read()
'\nEtiam rhoncus....
...metus at tortor pulvinar varius.\n'
>>> f = open('Desktop/lorumipsum.txt')
>>> f.readlines()
['Lorem ipsum dolor...

For the next lesson click here.


Popular post

Which Forex Pairs are Generally Trending and Which Ones Tend to Revert to the Mean

Build more wealth with gold

Get links to data referenced by plus500.com